Socket
Socket
Sign inDemoInstall

@esri/hub-discussions

Package Overview
Dependencies
Maintainers
44
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 9.5.0 to 9.6.0

2

dist/es2017/types.js

@@ -61,2 +61,3 @@ /**

*/
// TODO: Deprecate ITEM and DATASET keys at v10.0.0
export var DiscussionType;

@@ -67,2 +68,3 @@ (function (DiscussionType) {

DiscussionType["GROUP"] = "group";
DiscussionType["CONTENT"] = "content";
})(DiscussionType || (DiscussionType = {}));

@@ -69,0 +71,0 @@ /**

55

dist/es2017/utils/posts.js

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

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

@@ -7,12 +6,18 @@ /**

* @export
* @param {string} discussion
* @return {*} {IDiscussionParams}
* @param {string} discussion A discussion URI
* @return {string}
*/
export function parseDiscussionURI(discussion) {
// pass it through browser/node URL to invalidate plain strings
const uri = new URL(discussion) && new UrlParse(discussion);
const source = uri.protocol.slice(0, -1); // removes ":"
const type = uri.hostname;
const [, identifier] = uri.pathname.split("/");
let id, layer;
let url;
try {
url = new URL(discussion);
}
catch (e) {
throw new Error(`Invalid URI: ${discussion}`);
}
const source = url.protocol.replace(":", "");
const [, pathname] = discussion.split("://");
const [type, identifier] = pathname.split("/");
let id;
let layer;
if (identifier) {

@@ -22,3 +27,3 @@ const { itemId, layerId } = parseDatasetId(identifier);

}
const searchParams = new URLSearchParams(uri.query);
const searchParams = new URLSearchParams(url.search.replace("?", ""));
const features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

@@ -32,25 +37,43 @@ const attribute = (searchParams.has("attribute") && searchParams.get("attribute")) || null;

features,
attribute
attribute,
};
}
/**
* NOT IMPLEMENTED: this will inspect a group's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect a group"s properties to determine if it is "discussable"
*
* @export
* @param {IGroup} group
* @return {*} {boolean}
* @return {boolean}
*/
export function isGroupDiscussable(group) {
return true;
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isGroupDiscussable will be removed at v10.0.0");
return isDiscussable(group);
}
/**
* NOT IMPLEMENTED: this will inspect an item's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect an item"s properties to determine if it is "discussable"
*
* @export
* @param {IItem} item
* @return {*} {boolean}
* @return {boolean}
*/
export function isItemDiscussable(item) {
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isItemDiscussable will be removed at v10.0.0");
return isDiscussable(item);
}
/**
* Utility to determine if a given IGroup, IItem or IHubContent
* is discussable.
*
* NOT IMPLEMENTED
*
* @export
* @param {IGroup|IItem|IHubContent} The subject to evaluate
* @return {boolean}
*/
export function isDiscussable(subject) {
// TODO: implement
return true;
}
//# sourceMappingURL=posts.js.map

@@ -61,2 +61,3 @@ /**

*/
// TODO: Deprecate ITEM and DATASET keys at v10.0.0
export var DiscussionType;

@@ -67,2 +68,3 @@ (function (DiscussionType) {

DiscussionType["GROUP"] = "group";
DiscussionType["CONTENT"] = "content";
})(DiscussionType || (DiscussionType = {}));

@@ -69,0 +71,0 @@ /**

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

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

@@ -7,18 +6,24 @@ /**

* @export
* @param {string} discussion
* @return {*} {IDiscussionParams}
* @param {string} discussion A discussion URI
* @return {string}
*/
export function parseDiscussionURI(discussion) {
var _a;
// pass it through browser/node URL to invalidate plain strings
var uri = new URL(discussion) && new UrlParse(discussion);
var source = uri.protocol.slice(0, -1); // removes ":"
var type = uri.hostname;
var _b = uri.pathname.split("/"), identifier = _b[1];
var id, layer;
var url;
try {
url = new URL(discussion);
}
catch (e) {
throw new Error("Invalid URI: " + discussion);
}
var source = url.protocol.replace(":", "");
var _b = discussion.split("://"), pathname = _b[1];
var _c = pathname.split("/"), type = _c[0], identifier = _c[1];
var id;
var layer;
if (identifier) {
var _c = parseDatasetId(identifier), itemId = _c.itemId, layerId = _c.layerId;
var _d = parseDatasetId(identifier), itemId = _d.itemId, layerId = _d.layerId;
_a = [itemId, layerId], id = _a[0], layer = _a[1];
}
var searchParams = new URLSearchParams(uri.query);
var searchParams = new URLSearchParams(url.search.replace("?", ""));
var features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

@@ -32,25 +37,43 @@ var attribute = (searchParams.has("attribute") && searchParams.get("attribute")) || null;

features: features,
attribute: attribute
attribute: attribute,
};
}
/**
* NOT IMPLEMENTED: this will inspect a group's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect a group"s properties to determine if it is "discussable"
*
* @export
* @param {IGroup} group
* @return {*} {boolean}
* @return {boolean}
*/
export function isGroupDiscussable(group) {
return true;
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isGroupDiscussable will be removed at v10.0.0");
return isDiscussable(group);
}
/**
* NOT IMPLEMENTED: this will inspect an item's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect an item"s properties to determine if it is "discussable"
*
* @export
* @param {IItem} item
* @return {*} {boolean}
* @return {boolean}
*/
export function isItemDiscussable(item) {
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isItemDiscussable will be removed at v10.0.0");
return isDiscussable(item);
}
/**
* Utility to determine if a given IGroup, IItem or IHubContent
* is discussable.
*
* NOT IMPLEMENTED
*
* @export
* @param {IGroup|IItem|IHubContent} The subject to evaluate
* @return {boolean}
*/
export function isDiscussable(subject) {
// TODO: implement
return true;
}
//# sourceMappingURL=posts.js.map

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

*/
// TODO: Deprecate ITEM and DATASET keys at v10.0.0
var DiscussionType;

@@ -70,2 +71,3 @@ (function (DiscussionType) {

DiscussionType["GROUP"] = "group";
DiscussionType["CONTENT"] = "content";
})(DiscussionType = exports.DiscussionType || (exports.DiscussionType = {}));

@@ -72,0 +74,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isItemDiscussable = exports.isGroupDiscussable = exports.parseDiscussionURI = void 0;
const UrlParse = require("url-parse");
exports.isDiscussable = exports.isItemDiscussable = exports.isGroupDiscussable = exports.parseDiscussionURI = void 0;
const hub_common_1 = require("@esri/hub-common");

@@ -10,12 +9,18 @@ /**

* @export
* @param {string} discussion
* @return {*} {IDiscussionParams}
* @param {string} discussion A discussion URI
* @return {string}
*/
function parseDiscussionURI(discussion) {
// pass it through browser/node URL to invalidate plain strings
const uri = new URL(discussion) && new UrlParse(discussion);
const source = uri.protocol.slice(0, -1); // removes ":"
const type = uri.hostname;
const [, identifier] = uri.pathname.split("/");
let id, layer;
let url;
try {
url = new URL(discussion);
}
catch (e) {
throw new Error(`Invalid URI: ${discussion}`);
}
const source = url.protocol.replace(":", "");
const [, pathname] = discussion.split("://");
const [type, identifier] = pathname.split("/");
let id;
let layer;
if (identifier) {

@@ -25,3 +30,3 @@ const { itemId, layerId } = hub_common_1.parseDatasetId(identifier);

}
const searchParams = new URLSearchParams(uri.query);
const searchParams = new URLSearchParams(url.search.replace("?", ""));
const features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

@@ -35,3 +40,3 @@ const attribute = (searchParams.has("attribute") && searchParams.get("attribute")) || null;

features,
attribute
attribute,
};

@@ -41,23 +46,42 @@ }

/**
* NOT IMPLEMENTED: this will inspect a group's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect a group"s properties to determine if it is "discussable"
*
* @export
* @param {IGroup} group
* @return {*} {boolean}
* @return {boolean}
*/
function isGroupDiscussable(group) {
return true;
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isGroupDiscussable will be removed at v10.0.0");
return isDiscussable(group);
}
exports.isGroupDiscussable = isGroupDiscussable;
/**
* NOT IMPLEMENTED: this will inspect an item's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect an item"s properties to determine if it is "discussable"
*
* @export
* @param {IItem} item
* @return {*} {boolean}
* @return {boolean}
*/
function isItemDiscussable(item) {
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isItemDiscussable will be removed at v10.0.0");
return isDiscussable(item);
}
exports.isItemDiscussable = isItemDiscussable;
/**
* Utility to determine if a given IGroup, IItem or IHubContent
* is discussable.
*
* NOT IMPLEMENTED
*
* @export
* @param {IGroup|IItem|IHubContent} The subject to evaluate
* @return {boolean}
*/
function isDiscussable(subject) {
// TODO: implement
return true;
}
exports.isItemDiscussable = isItemDiscussable;
exports.isDiscussable = isDiscussable;
//# sourceMappingURL=posts.js.map

@@ -75,3 +75,4 @@ import { IHubRequestOptions as _IHubRequestOptions } from "@esri/hub-common";

ITEM = "item",
GROUP = "group"
GROUP = "group",
CONTENT = "content"
}

@@ -78,0 +79,0 @@ /**

import { IGroup, IItem } from "@esri/arcgis-rest-portal";
import { IDiscussionParams } from "../types";
import { IHubContent } from "@esri/hub-common";
/**

@@ -7,21 +8,32 @@ * Utility that parses a discussion URI string into its component parts

* @export
* @param {string} discussion
* @return {*} {IDiscussionParams}
* @param {string} discussion A discussion URI
* @return {string}
*/
export declare function parseDiscussionURI(discussion: string): IDiscussionParams;
/**
* NOT IMPLEMENTED: this will inspect a group's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect a group"s properties to determine if it is "discussable"
*
* @export
* @param {IGroup} group
* @return {*} {boolean}
* @return {boolean}
*/
export declare function isGroupDiscussable(group: IGroup): boolean;
/**
* NOT IMPLEMENTED: this will inspect an item's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect an item"s properties to determine if it is "discussable"
*
* @export
* @param {IItem} item
* @return {*} {boolean}
* @return {boolean}
*/
export declare function isItemDiscussable(item: IItem): boolean;
/**
* Utility to determine if a given IGroup, IItem or IHubContent
* is discussable.
*
* NOT IMPLEMENTED
*
* @export
* @param {IGroup|IItem|IHubContent} The subject to evaluate
* @return {boolean}
*/
export declare function isDiscussable(subject: IGroup | IItem | IHubContent): boolean;
/* @preserve
* @esri/hub-discussions - v9.4.1 - Thu Nov 04 2021 10:02:07 GMT-0600 (Mountain Daylight Time)
* @esri/hub-discussions - v9.5.0 - Thu Nov 04 2021 11:25:55 GMT-0600 (Mountain Daylight Time)
* Copyright (c) 2021 Environmental Systems Research Institute, Inc.

@@ -382,2 +382,3 @@ * Apache-2.0

*/
// TODO: Deprecate ITEM and DATASET keys at v10.0.0
exports.DiscussionType = void 0;

@@ -388,2 +389,3 @@ (function (DiscussionType) {

DiscussionType["GROUP"] = "group";
DiscussionType["CONTENT"] = "content";
})(exports.DiscussionType || (exports.DiscussionType = {}));

@@ -436,710 +438,28 @@ /**

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/**
* Check if we're required to add a port number.
*
* @see https://url.spec.whatwg.org/#default-port
* @param {Number|String} port Port number we need to check
* @param {String} protocol Protocol we need to check against.
* @returns {Boolean} Is it a default port for the given protocol
* @api private
*/
var requiresPort = function required(port, protocol) {
protocol = protocol.split(':')[0];
port = +port;
if (!port) return false;
switch (protocol) {
case 'http':
case 'ws':
return port !== 80;
case 'https':
case 'wss':
return port !== 443;
case 'ftp':
return port !== 21;
case 'gopher':
return port !== 70;
case 'file':
return false;
}
return port !== 0;
};
var has = Object.prototype.hasOwnProperty
, undef;
/**
* Decode a URI encoded string.
*
* @param {String} input The URI encoded string.
* @returns {String|Null} The decoded string.
* @api private
*/
function decode(input) {
try {
return decodeURIComponent(input.replace(/\+/g, ' '));
} catch (e) {
return null;
}
}
/**
* Attempts to encode a given input.
*
* @param {String} input The string that needs to be encoded.
* @returns {String|Null} The encoded string.
* @api private
*/
function encode(input) {
try {
return encodeURIComponent(input);
} catch (e) {
return null;
}
}
/**
* Simple query string parser.
*
* @param {String} query The query string that needs to be parsed.
* @returns {Object}
* @api public
*/
function querystring(query) {
var parser = /([^=?#&]+)=?([^&]*)/g
, result = {}
, part;
while (part = parser.exec(query)) {
var key = decode(part[1])
, value = decode(part[2]);
//
// Prevent overriding of existing properties. This ensures that build-in
// methods like `toString` or __proto__ are not overriden by malicious
// querystrings.
//
// In the case if failed decoding, we want to omit the key/value pairs
// from the result.
//
if (key === null || value === null || key in result) continue;
result[key] = value;
}
return result;
}
/**
* Transform a query string to an object.
*
* @param {Object} obj Object that should be transformed.
* @param {String} prefix Optional prefix.
* @returns {String}
* @api public
*/
function querystringify(obj, prefix) {
prefix = prefix || '';
var pairs = []
, value
, key;
//
// Optionally prefix with a '?' if needed
//
if ('string' !== typeof prefix) prefix = '?';
for (key in obj) {
if (has.call(obj, key)) {
value = obj[key];
//
// Edge cases where we actually want to encode the value to an empty
// string instead of the stringified value.
//
if (!value && (value === null || value === undef || isNaN(value))) {
value = '';
}
key = encode(key);
value = encode(value);
//
// If we failed to encode the strings, we should bail out as we don't
// want to add invalid strings to the query.
//
if (key === null || value === null) continue;
pairs.push(key +'='+ value);
}
}
return pairs.length ? prefix + pairs.join('&') : '';
}
//
// Expose the module.
//
var stringify = querystringify;
var parse = querystring;
var querystringify_1 = {
stringify: stringify,
parse: parse
};
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]'
, left = new RegExp('^'+ whitespace +'+');
/**
* Trim a given string.
*
* @param {String} str String to trim.
* @public
*/
function trimLeft(str) {
return (str ? str : '').toString().replace(left, '');
}
/**
* These are the parse rules for the URL parser, it informs the parser
* about:
*
* 0. The char it Needs to parse, if it's a string it should be done using
* indexOf, RegExp using exec and NaN means set as current value.
* 1. The property we should set when parsing this value.
* 2. Indication if it's backwards or forward parsing, when set as number it's
* the value of extra chars that should be split off.
* 3. Inherit from location if non existing in the parser.
* 4. `toLowerCase` the resulting value.
*/
var rules = [
['#', 'hash'], // Extract from the back.
['?', 'query'], // Extract from the back.
function sanitize(address, url) { // Sanitize what is left of the address
return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address;
},
['/', 'pathname'], // Extract from the back.
['@', 'auth', 1], // Extract from the front.
[NaN, 'host', undefined, 1, 1], // Set left over value.
[/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
[NaN, 'hostname', undefined, 1, 1] // Set left over.
];
/**
* These properties should not be copied or inherited from. This is only needed
* for all non blob URL's as a blob URL does not include a hash, only the
* origin.
*
* @type {Object}
* @private
*/
var ignore = { hash: 1, query: 1 };
/**
* The location object differs when your code is loaded through a normal page,
* Worker or through a worker using a blob. And with the blobble begins the
* trouble as the location object will contain the URL of the blob, not the
* location of the page where our code is loaded in. The actual origin is
* encoded in the `pathname` so we can thankfully generate a good "default"
* location from it so we can generate proper relative URL's again.
*
* @param {Object|String} loc Optional default location object.
* @returns {Object} lolcation object.
* @public
*/
function lolcation(loc) {
var globalVar;
if (typeof window !== 'undefined') globalVar = window;
else if (typeof commonjsGlobal !== 'undefined') globalVar = commonjsGlobal;
else if (typeof self !== 'undefined') globalVar = self;
else globalVar = {};
var location = globalVar.location || {};
loc = loc || location;
var finaldestination = {}
, type = typeof loc
, key;
if ('blob:' === loc.protocol) {
finaldestination = new Url(unescape(loc.pathname), {});
} else if ('string' === type) {
finaldestination = new Url(loc, {});
for (key in ignore) delete finaldestination[key];
} else if ('object' === type) {
for (key in loc) {
if (key in ignore) continue;
finaldestination[key] = loc[key];
}
if (finaldestination.slashes === undefined) {
finaldestination.slashes = slashes.test(loc.href);
}
}
return finaldestination;
}
/**
* 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
* @type Object
* @property {String} protocol Protocol matched in the URL, in lowercase.
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
* @property {String} rest Rest of the URL that is not part of the protocol.
*/
/**
* Extract protocol information from a URL with/without double slash ("//").
*
* @param {String} address URL we want to extract from.
* @param {Object} location
* @return {ProtocolExtract} Extracted information.
* @private
*/
function extractProtocol(address, location) {
address = trimLeft(address);
location = location || {};
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: forwardSlashes || isSpecial(protocol),
slashesCount: slashesCount,
rest: rest
};
}
/**
* Resolve a relative URL pathname against a base URL pathname.
*
* @param {String} relative Pathname of the relative URL.
* @param {String} base Pathname of the base URL.
* @return {String} Resolved pathname.
* @private
*/
function resolve(relative, base) {
if (relative === '') return base;
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
, i = path.length
, last = path[i - 1]
, unshift = false
, up = 0;
while (i--) {
if (path[i] === '.') {
path.splice(i, 1);
} else if (path[i] === '..') {
path.splice(i, 1);
up++;
} else if (up) {
if (i === 0) unshift = true;
path.splice(i, 1);
up--;
}
}
if (unshift) path.unshift('');
if (last === '.' || last === '..') path.push('');
return path.join('/');
}
/**
* The actual URL instance. Instead of returning an object we've opted-in to
* create an actual constructor as it's much more memory efficient and
* faster and it pleases my OCD.
*
* It is worth noting that we should not use `URL` as class name to prevent
* clashes with the global URL instance that got introduced in browsers.
*
* @constructor
* @param {String} address URL we want to parse.
* @param {Object|String} [location] Location defaults for relative paths.
* @param {Boolean|Function} [parser] Parser for the query string.
* @private
*/
function Url(address, location, parser) {
address = trimLeft(address);
if (!(this instanceof Url)) {
return new Url(address, location, parser);
}
var relative, extracted, parse, instruction, index, key
, instructions = rules.slice()
, type = typeof location
, url = this
, i = 0;
//
// The following if statements allows this module two have compatibility with
// 2 different API:
//
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
// where the boolean indicates that the query string should also be parsed.
//
// 2. The `URL` interface of the browser which accepts a URL, object as
// arguments. The supplied object will be used as default values / fall-back
// for relative paths.
//
if ('object' !== type && 'string' !== type) {
parser = location;
location = null;
}
if (parser && 'function' !== typeof parser) parser = querystringify_1.parse;
location = lolcation(location);
//
// Extract protocol information before running the instructions.
//
extracted = extractProtocol(address || '', location);
relative = !extracted.protocol && !extracted.slashes;
url.slashes = extracted.slashes || relative && location.slashes;
url.protocol = extracted.protocol || location.protocol || '';
address = extracted.rest;
//
// When the authority component is absent the URL starts with a path
// component.
//
if (
extracted.protocol === 'file:' && (
extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
(!extracted.slashes &&
(extracted.protocol ||
extracted.slashesCount < 2 ||
!isSpecial(url.protocol)))
) {
instructions[3] = [/(.*)/, 'pathname'];
}
for (; i < instructions.length; i++) {
instruction = instructions[i];
if (typeof instruction === 'function') {
address = instruction(address, url);
continue;
}
parse = instruction[0];
key = instruction[1];
if (parse !== parse) {
url[key] = address;
} else if ('string' === typeof parse) {
if (~(index = address.indexOf(parse))) {
if ('number' === typeof instruction[2]) {
url[key] = address.slice(0, index);
address = address.slice(index + instruction[2]);
} else {
url[key] = address.slice(index);
address = address.slice(0, index);
}
}
} else if ((index = parse.exec(address))) {
url[key] = index[1];
address = address.slice(0, index.index);
}
url[key] = url[key] || (
relative && instruction[3] ? location[key] || '' : ''
);
//
// Hostname, host and protocol should be lowercased so they can be used to
// create a proper `origin`.
//
if (instruction[4]) url[key] = url[key].toLowerCase();
}
//
// Also parse the supplied query string in to an object. If we're supplied
// with a custom parser as function use that instead of the default build-in
// parser.
//
if (parser) url.query = parser(url.query);
//
// If the URL is relative, resolve the pathname against the base URL.
//
if (
relative
&& location.slashes
&& url.pathname.charAt(0) !== '/'
&& (url.pathname !== '' || location.pathname !== '')
) {
url.pathname = resolve(url.pathname, location.pathname);
}
//
// Default to a / for pathname if none exists. This normalizes the URL
// to always have a /
//
if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {
url.pathname = '/' + url.pathname;
}
//
// We should not add port numbers if they are already the default port number
// for a given protocol. As the host also contains the port number we're going
// override it with the hostname which contains no port number.
//
if (!requiresPort(url.port, url.protocol)) {
url.host = url.hostname;
url.port = '';
}
//
// Parse down the `auth` for the username and password.
//
url.username = url.password = '';
if (url.auth) {
instruction = url.auth.split(':');
url.username = instruction[0] || '';
url.password = instruction[1] || '';
}
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
? url.protocol +'//'+ url.host
: 'null';
//
// The href is just the compiled result.
//
url.href = url.toString();
}
/**
* This is convenience method for changing properties in the URL instance to
* insure that they all propagate correctly.
*
* @param {String} part Property we need to adjust.
* @param {Mixed} value The newly assigned value.
* @param {Boolean|Function} fn When setting the query, it will be the function
* used to parse the query.
* When setting the protocol, double slash will be
* removed from the final url if it is true.
* @returns {URL} URL instance for chaining.
* @public
*/
function set(part, value, fn) {
var url = this;
switch (part) {
case 'query':
if ('string' === typeof value && value.length) {
value = (fn || querystringify_1.parse)(value);
}
url[part] = value;
break;
case 'port':
url[part] = value;
if (!requiresPort(value, url.protocol)) {
url.host = url.hostname;
url[part] = '';
} else if (value) {
url.host = url.hostname +':'+ value;
}
break;
case 'hostname':
url[part] = value;
if (url.port) value += ':'+ url.port;
url.host = value;
break;
case 'host':
url[part] = value;
if (/:\d+$/.test(value)) {
value = value.split(':');
url.port = value.pop();
url.hostname = value.join(':');
} else {
url.hostname = value;
url.port = '';
}
break;
case 'protocol':
url.protocol = value.toLowerCase();
url.slashes = !fn;
break;
case 'pathname':
case 'hash':
if (value) {
var char = part === 'pathname' ? '/' : '#';
url[part] = value.charAt(0) !== char ? char + value : value;
} else {
url[part] = value;
}
break;
default:
url[part] = value;
}
for (var i = 0; i < rules.length; i++) {
var ins = rules[i];
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
}
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
? url.protocol +'//'+ url.host
: 'null';
url.href = url.toString();
return url;
}
/**
* Transform the properties back in to a valid and full URL string.
*
* @param {Function} stringify Optional query stringify function.
* @returns {String} Compiled version of the URL.
* @public
*/
function toString(stringify) {
if (!stringify || 'function' !== typeof stringify) stringify = querystringify_1.stringify;
var query
, url = this
, protocol = url.protocol;
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
var result = protocol + (url.slashes || isSpecial(url.protocol) ? '//' : '');
if (url.username) {
result += url.username;
if (url.password) result += ':'+ url.password;
result += '@';
}
result += url.host + url.pathname;
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
if (url.hash) result += url.hash;
return result;
}
Url.prototype = { set: set, toString: toString };
//
// Expose the URL parser and some additional properties that might be useful for
// others or testing.
//
Url.extractProtocol = extractProtocol;
Url.location = lolcation;
Url.trimLeft = trimLeft;
Url.qs = querystringify_1;
var urlParse = Url;
var UrlParse = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), urlParse, {
'default': urlParse
}));
/**
* Utility that parses a discussion URI string into its component parts
*
* @export
* @param {string} discussion
* @return {*} {IDiscussionParams}
* @param {string} discussion A discussion URI
* @return {string}
*/
function parseDiscussionURI(discussion) {
var _a;
// pass it through browser/node URL to invalidate plain strings
var uri = new URL(discussion) && new UrlParse(discussion);
var source = uri.protocol.slice(0, -1); // removes ":"
var type = uri.hostname;
var _b = uri.pathname.split("/"), identifier = _b[1];
var id, layer;
var url;
try {
url = new URL(discussion);
}
catch (e) {
throw new Error("Invalid URI: " + discussion);
}
var source = url.protocol.replace(":", "");
var _b = discussion.split("://"), pathname = _b[1];
var _c = pathname.split("/"), type = _c[0], identifier = _c[1];
var id;
var layer;
if (identifier) {
var _c = hubCommon.parseDatasetId(identifier), itemId = _c.itemId, layerId = _c.layerId;
var _d = hubCommon.parseDatasetId(identifier), itemId = _d.itemId, layerId = _d.layerId;
_a = [itemId, layerId], id = _a[0], layer = _a[1];
}
var searchParams = new URLSearchParams(uri.query);
var searchParams = new URLSearchParams(url.search.replace("?", ""));
var features = (searchParams.has("id") && searchParams.get("id").split(",")) || null;

@@ -1153,23 +473,41 @@ var attribute = (searchParams.has("attribute") && searchParams.get("attribute")) || null;

features: features,
attribute: attribute
attribute: attribute,
};
}
/**
* NOT IMPLEMENTED: this will inspect a group's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect a group"s properties to determine if it is "discussable"
*
* @export
* @param {IGroup} group
* @return {*} {boolean}
* @return {boolean}
*/
function isGroupDiscussable(group) {
return true;
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isGroupDiscussable will be removed at v10.0.0");
return isDiscussable();
}
/**
* NOT IMPLEMENTED: this will inspect an item's properties to determine if it is "discussable"
* NOT IMPLEMENTED: this will inspect an item"s properties to determine if it is "discussable"
*
* @export
* @param {IItem} item
* @return {*} {boolean}
* @return {boolean}
*/
function isItemDiscussable(item) {
/* tslint:disable no-console */
console.warn("DEPRECATED: Use isDiscussable() instead. isItemDiscussable will be removed at v10.0.0");
return isDiscussable();
}
/**
* Utility to determine if a given IGroup, IItem or IHubContent
* is discussable.
*
* NOT IMPLEMENTED
*
* @export
* @param {IGroup|IItem|IHubContent} The subject to evaluate
* @return {boolean}
*/
function isDiscussable(subject) {
// TODO: implement
return true;

@@ -1370,2 +708,3 @@ }

exports.isChannelInclusive = isChannelInclusive;
exports.isDiscussable = isDiscussable;
exports.isGroupDiscussable = isGroupDiscussable;

@@ -1372,0 +711,0 @@ exports.isItemDiscussable = isItemDiscussable;

@@ -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,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=a.buildUrl({host:t.hubApiUrl||"https://hub.arcgis.com",path:"/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})});
!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 o,t,r,s,i=(o=a.RemoteServerError,n(t=u,r=o),t.prototype=null===r?Object.create(r):(c.prototype=r.prototype,new c),u);function c(){this.constructor=t}function u(e,t,n,r){n=o.call(this,e,t,n)||this;return n.error=r,n}function p(t,n){return e=n,r=n.token,o=n.authentication,e=function(){return Promise.resolve(r)},(e=o?o.getToken.bind(o,o.portal):e)().then(function(e){return function(e,t,n){var r=new Headers;r.append("Content-Type","application/json"),n&&r.append("Authorization","Bearer "+n),n={headers:r,method:t.httpMethod||"GET",mode:t.mode,cache:t.cache,credentials:t.credentials},r=a.buildUrl({host:t.hubApiUrl||"https://hub.arcgis.com",path:"/api/discussions/v1"}),t.params&&("GET"===t.httpMethod?e+="?"+new URLSearchParams(t.params).toString():n.body=JSON.stringify(t.params));var o=[r.replace(/\/$/,""),e.replace(/^\//,"")].join("/");return fetch(o,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,o,n,JSON.stringify(e.message))})})}(t,n,e)});var e,r,o}function d(e){return!0}function h(n){return function(e,t){return-1<n.indexOf(t.userMembership.memberType)&&e.push(t.id),e}}function l(e){return"org_admin"===e.role&&!e.roleId}function f(r,o){return function(e,t){var t=t.groups,n=e.groups.reduce(h(r),[]);return t[o?"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 v(e,t){return l(t)&&-1<e.orgs.indexOf(t.orgId)}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",s.CONTENT="content",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",e.canCreateChannel=function(e,t){return"private"===e.access?f(["owner","admin","member"],!0)(t,e):v(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?f(["owner","admin"])(t,e):v(e,t)},e.canPostToChannel=function(e,t){return"private"===e.access?f(["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?f(["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,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.isDiscussable=d,e.isGroupDiscussable=function(e){return console.warn("DEPRECATED: Use isDiscussable() instead. isGroupDiscussable will be removed at v10.0.0"),!0},e.isItemDiscussable=function(e){return console.warn("DEPRECATED: Use isDiscussable() instead. isItemDiscussable will be removed at v10.0.0"),!0},e.isOrgAdmin=l,e.parseDiscussionURI=function(t){try{s=new URL(t)}catch(e){throw new Error("Invalid URI: "+t)}var e,n,r=s.protocol.replace(":",""),o=t.split("://")[1].split("/"),t=o[0];(o=o[1])&&(e=(n=[(e=a.parseDatasetId(o)).itemId,e.layerId])[0],n=n[1]);var s=new URLSearchParams(s.search.replace("?",""));return{source:r,type:t,id:e||null,layer:n||null,features:s.has("id")&&s.get("id").split(",")||null,attribute:s.has("attribute")&&s.get("attribute")||null}},e.reduceByGroupMembership=h,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": "9.5.0",
"version": "9.6.0",
"description": "Module to interact with ArcGIS Hub Discussions API in Node.js and modern browsers.",

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

"dependencies": {
"tslib": "^1.13.0",
"url-parse": "^1.5.1"
"tslib": "^1.13.0"
},

@@ -26,3 +25,3 @@ "peerDependencies": {

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

@@ -32,3 +31,2 @@ "@rollup/plugin-json": "^4.1.0",

"@types/geojson": "^7946.0.7",
"@types/url-parse": "^1.4.3",
"rollup": "^2.26.5",

@@ -75,3 +73,3 @@ "rollup-plugin-filesize": "^9.0.2",

"homepage": "https://github.com/Esri/hub.js#readme",
"gitHead": "eb93539d3e66c80f4f394bb97323944bf9c1fd89",
"gitHead": "f58d63cabfdfee70178eae5af54da4e97131989e",
"volta": {

@@ -78,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

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