import { IPagingParams, IPagedResponse as IRestPagedResponse, IUser } from "@esri/arcgis-rest-portal"; import type { Geometry, Polygon } from "geojson"; import { IHubRequestOptions } from "../../hub-types"; import { TSharingAccess } from "./enums/sharingAccess"; import { TPostStatus } from "./enums/postStatus"; import { TPostType } from "./enums/postType"; import { TPostReaction } from "./enums/postReaction"; import { TSortOrder } from "./enums/sortOrder"; import { TPostRelation } from "./enums/postRelation"; import { TPostSort } from "./enums/postSort"; import { TSearchPostsFormat } from "./enums/searchPostsFormat"; import { TRole } from "./enums/role"; import { TChannelFilter } from "./enums/channelFilter"; import { TAclCategory } from "./enums/aclCategory"; import { TAclSubCategory } from "./enums/aclSubCategory"; import { TChannelRelation } from "./enums/channelRelation"; import { TChannelSort } from "./enums/channelSort"; import { TEntitySettingType } from "./enums/entitySettingsType"; /** * representation of AGOL platform sharing ACL * NOTE: orgs is an array to enable future org-org sharing/discussion * * @export * @interface IPlatformSharing */ export interface IPlatformSharing { groups: string[]; orgs: string[]; access: TSharingAccess; } /** * named parts of a discussion URI, follows this convention: * ${source}://${type}/${id}_${layer}?features=${...features}&attribute=${attribute} * * coarse-grained uri - hub://item/ab3 -- commenting from hub about item ab3 * -- * fine-grained uri - hub://dataset/3ef_0?features=10,32&attribute=species -- commenting from * hub about species attribute of features id 10 & 32 in dataset 3ef layer 0 * * @export * @interface IDiscussionParams */ export interface IDiscussionParams { source: string | null; type: string | null; id: string | null; layer: string | null; features: string[] | null; attribute: string | null; } /** * creator property * * @export * @interface IWithAuthor */ export interface IWithAuthor { creator: string; } /** * editor property * * @export * @interface IWithEditor */ export interface IWithEditor { editor: string; } /** * sorting properties * * @export * @interface IWithSorting */ export interface IWithSorting { sortBy: SortEnum; sortOrder: TSortOrder; } /** * filtering properties * * @export * @interface IWithFiltering */ export interface IWithFiltering { filterBy: FilterEnum; } /** * properties that enable temporal querying * * @export * @interface IWithTimeQueries */ export interface IWithTimeQueries { createdBefore: Date; createdAfter: Date; updatedBefore: Date; updatedAfter: Date; } /** * temporal properties * * @export * @interface IWithTimestamps */ export interface IWithTimestamps { createdAt: Date; updatedAt: Date; } /** * paginated response properties * * @export * @interface IPagedResponse * @extends {IRestPagedResponse} * @template PaginationObject */ export interface IPagedResponse extends IRestPagedResponse { items: PaginationObject[]; } /** * delete notifications opt out response properties * * @export * @interface IRemoveChannelNotificationOptOutResult */ export interface IRemoveChannelNotificationOptOutResult { success: boolean; channelId: string; username: string; } /** * delete channel activity response properties * * @export * @interface IRemoveChannelActivityResult */ export interface IRemoveChannelActivityResult { success: boolean; channelId: string; username: string; } /** * opt out response properties * * @export * @interface IChannelNotificationOptOut */ export interface IChannelNotificationOptOut { channelId: string; username: string; } /** * options for making requests against Discussion API * * @export * @interface IDiscussionsRequestOptions * @extends {RequestInit} */ export interface IDiscussionsRequestOptions extends Omit, Pick { httpMethod?: "GET" | "POST" | "PATCH" | "DELETE"; isPortal?: boolean; token?: string; data?: { [key: string]: any; }; } /** * Interface representing the meta data associated with a discussions * mention email * * @export * @interface IDiscussionsMentionMeta */ export interface IDiscussionsMentionMeta { channelId: string; discussion: string; postId: string; replyId?: string; } /** * @export * @interface IDiscussionsUser * @extends {IUser} */ export interface IDiscussionsUser extends IUser { username?: string | null; } /** * representation of reaction from the service * * @export * @interface IReaction * @extends {IWithAuthor} * @extends {IWithEditor} * @extends {IWithTimestamps} */ export interface IReaction extends IWithAuthor, IWithEditor, IWithTimestamps { id: string; value: TPostReaction; postId?: string; post?: IPost; } /** * dto for creating a reaction * * @export * @interface ICreateReaction */ export interface ICreateReaction { postId: string; value: TPostReaction; } /** * request options for creating a reaction to a post * * @export * @interface ICreateReactionOptions * @extends {IHubRequestOptions} */ export interface ICreateReactionOptions extends IDiscussionsRequestOptions { data: ICreateReaction; } /** * request options for deleting a reaction * * @export * @interface IRemoveReactionOptions * @extends {IHubRequestOptions} */ export interface IRemoveReactionOptions extends IDiscussionsRequestOptions { reactionId: string; } /** * delete reaction response properties * * @export * @interface IRemoveReactionResponse */ export interface IRemoveReactionResponse { success: boolean; reactionId: string; } /** * representation of post from service * * @export * @interface IPost * @extends {IWithAuthor} * @extends {IWithEditor} * @extends {IWithTimestamps} */ export interface IPost extends Partial, Partial, IWithTimestamps { id: string; title: string | null; body: string; status: TPostStatus; appInfo: string | null; discussion: string | null; geometry: Geometry | null; featureGeometry: Geometry | null; postType: TPostType; channelId: string; channel?: IChannel; parentId?: string; parent?: IPost | null; replies?: IPost[] | IPagedResponse; replyCount?: number; reactions?: IReaction[]; } /** * base parameters for creating a post * * @export * @interface IPostOptions */ export interface IPostOptions { body: string; title?: string; discussion?: string; geometry?: Geometry; featureGeometry?: Geometry; appInfo?: string; asAnonymous?: boolean; } /** * dto for creating a post in a known channel * * @export * @interface ICreatePost * @extends {IPostOptions} */ export interface ICreatePost extends IPostOptions { channelId: string; } /** * request options for creating v2 post * * @export * @interface ICreatePostParamsV2 * @extends {IDiscussionsRequestOptions} */ export interface ICreatePostParamsV2 extends IDiscussionsRequestOptions { data: ICreatePost; mentionUrl?: string; } /** * request options for creating reply to post * * @export * @interface ICreateReplyParams * @extends {IHubRequestOptions} */ export interface ICreateReplyParams extends IDiscussionsRequestOptions { postId: string; data: IPostOptions; mentionUrl?: string; } /** * dto for decorating found post with relations * * @export * @interface IFetchPost * @extends {Partial} */ export interface IFetchPost extends Partial { relations?: TPostRelation[]; } /** * dto for searching posts * * @export * @interface ISearchChannelPosts * @extends {Partial} * @extends {Partial>} * @extends {Partial} */ export interface ISearchPosts extends Partial, Partial>, Partial { access?: TSharingAccess[]; body?: string; channels?: string[]; creator?: string | null; discussion?: string | null; editor?: string | null; f?: TSearchPostsFormat; featureGeometry?: Geometry; geometry?: Geometry; groups?: string[] | null; parents?: string[] | null; postType?: TPostType; relations?: TPostRelation[]; status?: TPostStatus[]; title?: string; term?: string; } /** * dto for updating a post's status * * @export * @interface IUpdatePostStatus */ export interface IUpdatePostStatus { status: TPostStatus; } /** * dto for updating a post's content * * @export * @interface IUpdatePost */ export interface IUpdatePost { asAnonymous?: boolean; title?: string; body?: string; discussion?: string | null; geometry?: Geometry | null; featureGeometry?: Geometry | null; appInfo?: string | null; } /** * request options for querying posts * * @export * @interface ISearchPostsParams * @extends {IDiscussionsRequestOptions} */ export interface ISearchPostsParams extends IDiscussionsRequestOptions { data?: ISearchPosts; } /** * request options for exporting posts as CSV * * @export * @interface IExportPostsParams * @extends {IDiscussionsRequestOptions} */ export interface IExportPostsParams extends IDiscussionsRequestOptions { data?: ISearchPosts; } /** * request params for getting post * * @export * @interface IFetchPostParams * @extends {IDiscussionsRequestOptions} */ export interface IFetchPostParams extends IDiscussionsRequestOptions { postId: string; data?: IFetchPost; } /** * request options for updating post * * @export * @interface IUpdatePostParams * @extends {IDiscussionsRequestOptions} */ export interface IUpdatePostParams extends IDiscussionsRequestOptions { postId: string; data: IUpdatePost; mentionUrl?: string; } /** * request options for updating a post's status * * @export * @interface IUpdatePostStatusParams * @extends {IDiscussionsRequestOptions} */ export interface IUpdatePostStatusParams extends IDiscussionsRequestOptions { postId: string; data: IUpdatePostStatus; } /** * request options for deleting a post * * @export * @interface IRemovePostParams * @extends {IDiscussionsRequestOptions} */ export interface IRemovePostParams extends IDiscussionsRequestOptions { postId: string; } /** * delete post response properties * * @export * @interface IRemovePostResponse */ export interface IRemovePostResponse { success: boolean; postId: string; } /** * request option for creating a channel ACL permission * * @export * @interface IChannelAclPermissionDefinition */ export interface IChannelAclPermissionDefinition { category: TAclCategory; /** Only valid for category: `group` or `org` */ subCategory?: TAclSubCategory; /** Ago `group_id` or `org_id` or `user.username`. Invalid for category: `anonymousUser, authenticatedUser` */ key?: string; role: TRole; restrictedBefore?: string; } /** * request option for updating a channel ACL permission * * @export * @interface IChannelAclUpdateDefinition */ export interface IChannelAclUpdateDefinition extends IChannelAclPermissionDefinition { id?: string; } /** * request option for updating a channel ACL permission * * @export * @interface IChannelAclPermissionUpdateDefinition * @extends {IChannelAclPermissionDefinition} */ export interface IChannelAclPermissionUpdateDefinition extends IChannelAclPermissionDefinition { channelId: string; } /** * representation of channelAcl permission from service * * @export * @interface IChannelAclPermission * @extends {IChannelAclPermissionDefinition} * @extends {IWithAuthor} * @extends {IWithEditor} * @extends {IWithTimestamps} */ export interface IChannelAclPermission extends IChannelAclPermissionDefinition, IWithAuthor, IWithEditor, IWithTimestamps { id: string; channelId: string; restrictedBefore: string; } /** * settings parameters for creating a V2 channel * * @export * @interface ICreateChannelSettingsV2 */ export interface ICreateChannelSettingsV2 { allowAsAnonymous?: boolean; allowedReactions?: TPostReaction[]; allowPost?: boolean; allowReaction?: boolean; allowReply?: boolean; blockWords?: string[]; defaultPostStatus?: TPostStatus; metadata?: IChannelMetadata; name: string; softDelete?: boolean; } /** * @export * @interface IChannelMetadata */ export interface IChannelMetadata { guidelineUrl?: string | null; } /** * permissions parameters for creating a V2 channel * * @export * @interface ICreateChannelPermissionsV2 */ export interface ICreateChannelPermissionsV2 { channelAclDefinition: IChannelAclPermissionDefinition[]; } /** * permissions parameters for updating a V2 channel * * @export * @interface IUpdateChannelPermissionsV2 */ export interface IUpdateChannelPermissionsV2 { channelAclDefinition?: IChannelAclUpdateDefinition[]; } /** * parameters for creating a V2 channel * * @export * @interface ICreateChannelV2 * @extends {ICreateChannelSettingsV2} * @extends {ICreateChannelPermissionsV2} */ export interface ICreateChannelV2 extends ICreateChannelSettingsV2, ICreateChannelPermissionsV2 { } /** * representation of channel from service * * @export * @interface IChannel * @extends {IWithAuthor} * @extends {IWithEditor} * @extends {IWithTimestamps} */ export interface IChannel extends IWithAuthor, IWithEditor, IWithTimestamps { id: string; allowAsAnonymous: boolean; allowedReactions: TPostReaction[] | null; allowPost: boolean; allowReaction: boolean; allowReply: boolean; blockWords: string[] | null; channelAcl?: IChannelAclPermission[]; defaultPostStatus: TPostStatus; metadata: IChannelMetadata | null; name: string | null; orgId: string; posts?: IPost[]; softDelete: boolean; } /** * parameters for updating a channel * * @export * @interface IUpdateChannelV2 * @extends {IUpdateChannelSettingsV2} * @extends {IUpdateChannelPermissionsV2} */ export interface IUpdateChannelV2 extends IUpdateChannelSettingsV2, IUpdateChannelPermissionsV2 { } /** * settings parameters for updating a channel * * @export * @interface IUpdateChannelSettingsV2 */ export interface IUpdateChannelSettingsV2 { allowAsAnonymous?: boolean; allowedReactions?: TPostReaction[]; allowPost?: boolean; allowReaction?: boolean; allowReply?: boolean; blockWords?: string[]; defaultPostStatus?: TPostStatus; metadata?: IChannelMetadata; name?: string; softDelete?: boolean; } /** * dto for decorating found channel with relations * * @export * @interface IFetchChannel */ export interface IFetchChannel { relations?: TChannelRelation[]; } /** * dto for querying channels * * @export * @interface ISearchChannels * @extends {Partial} * @extends {Partial>} * @extends {Partial} * @extends {Partial>} * @extends {Partial} * @extends {Partial} */ export interface ISearchChannels extends Partial, Partial>, Partial, Partial>, Partial, Partial { access?: TSharingAccess[]; discussion?: string; groups?: string[]; /** cannot be used with notIds */ ids?: string[]; /** cannot be used with ids */ notIds?: string[]; name?: string; orgIds?: string[]; relations?: TChannelRelation[]; removeNonDiscussableGroups?: boolean; roles?: TRole[]; } /** * request params for creating a V2 channel * * @export * @interface ICreateChannelParamsV2 * @extends {IDiscussionsRequestOptions} */ export interface ICreateChannelParamsV2 extends IDiscussionsRequestOptions { data: ICreateChannelV2; } /** * request params for getting a channel * * @export * @interface IFetchChannelParams * @extends {IDiscussionsRequestOptions} */ export interface IFetchChannelParams extends IDiscussionsRequestOptions { channelId: string; data?: IFetchChannel; } /** * request params for searching channels * * @export * @interface ISearchChannelsParams * @extends {IDiscussionsRequestOptions} */ export interface ISearchChannelsParams extends IDiscussionsRequestOptions { data?: ISearchChannels; } /** * request params for updating a V2 channel * * @export * @interface IUpdateChannelParamsV2 * @extends {IDiscussionsRequestOptions} */ export interface IUpdateChannelParamsV2 extends IDiscussionsRequestOptions { channelId: string; data: IUpdateChannelV2; } /** * request params for deleting a channel * * @export * @interface IRemoveChannelParams * @extends {IDiscussionsRequestOptions} */ export interface IRemoveChannelParams extends IDiscussionsRequestOptions { channelId: string; } /** * delete channel response properties * * @export * @interface IRemoveChannelResponse */ export interface IRemoveChannelResponse { success: boolean; channelId: string; } /** * request params for fetching opt out status * * @export * @interface IFetchChannelNotificationOptOutParams * @extends {IDiscussionsRequestOptions} */ export interface IFetchChannelNotificationOptOutParams extends IDiscussionsRequestOptions { channelId: string; } /** * request params for opting out * * @export * @interface ICreateChannelNotificationOptOutParams * @extends {IDiscussionsRequestOptions} */ export interface ICreateChannelNotificationOptOutParams extends IDiscussionsRequestOptions { channelId: string; } /** * request params for opting back in * * @export * @interface IRemoveChannelNotificationOptOutParams * @extends {IDiscussionsRequestOptions} */ export interface IRemoveChannelNotificationOptOutParams extends IDiscussionsRequestOptions { channelId: string; } /** * request params for deleting channel activity * * @export * @interface IRemoveChannelActivityParams * @extends {IDiscussionsRequestOptions} */ export interface IRemoveChannelActivityParams extends IDiscussionsRequestOptions { channelId: string; } /** * representation of an entity setting record from the service * * @export * @interface IEntitySetting * @extends {IWithAuthor} * @extends {IWithEditor} * @extends {IWithTimestamps} */ export interface IEntitySetting extends IWithAuthor, IWithEditor, IWithTimestamps { id: string; type: TEntitySettingType; settings: IEntitySettings; } /** * @export * @interface IEntitySettings */ export interface IEntitySettings { discussions?: IDiscussionsSettings; } /** * @export * @interface IDiscussionsSettings */ export interface IDiscussionsSettings { allowedChannelIds?: string[] | null; allowedLocations?: Polygon[] | null; } /** * @export * @interface IRemoveSettingResponse */ export interface IRemoveSettingResponse { id: string; success: boolean; } /** * @export * @interface ICreateSetting */ export interface ICreateSetting { id: string; type: TEntitySettingType; settings: IEntitySettings; } /** * @export * @interface IUpdateSetting */ export interface IUpdateSetting { settings: Partial; } /** * parameters for creating a setting * * @export * @interface ICreateSettingParams * @extends {IDiscussionsRequestOptions} */ export interface ICreateSettingParams extends IDiscussionsRequestOptions { data: ICreateSetting; } /** * parameters for fetching a setting * * @export * @interface IFetchSettingParams * @extends {IDiscussionsRequestOptions} */ export interface IFetchSettingParams extends IDiscussionsRequestOptions { id: string; } /** * parameters for updating a setting * * @export * @interface IUpdateSettingParams * @extends {IDiscussionsRequestOptions} */ export interface IUpdateSettingParams extends IDiscussionsRequestOptions { id: string; data: IUpdateSetting; } /** * parameters for removing a setting * * @export * @interface IRemoveSettingParams * @extends {IDiscussionsRequestOptions} */ export interface IRemoveSettingParams extends IDiscussionsRequestOptions { id: string; }