@esri/hub-common 13.21.0 → 13.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/esm/core/types/index.js +1 -0
  2. package/dist/esm/core/types/index.js.map +1 -1
  3. package/dist/esm/discussions/api/channels/channels.js +14 -0
  4. package/dist/esm/discussions/api/channels/channels.js.map +1 -0
  5. package/dist/esm/discussions/api/channels/index.js +2 -0
  6. package/dist/esm/discussions/api/channels/index.js.map +1 -0
  7. package/dist/esm/discussions/api/index.js +3 -0
  8. package/dist/esm/discussions/api/index.js.map +1 -0
  9. package/dist/esm/discussions/api/request.js +20 -0
  10. package/dist/esm/discussions/api/request.js.map +1 -0
  11. package/dist/esm/discussions/api/types.js +244 -0
  12. package/dist/esm/discussions/api/types.js.map +1 -0
  13. package/dist/esm/discussions/api/utils/request.js +77 -0
  14. package/dist/esm/discussions/api/utils/request.js.map +1 -0
  15. package/dist/esm/discussions/index.js +1 -0
  16. package/dist/esm/discussions/index.js.map +1 -1
  17. package/dist/esm/index.js +3 -0
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/initiatives/HubInitiative.js +5 -12
  20. package/dist/esm/initiatives/HubInitiative.js.map +1 -1
  21. package/dist/esm/initiatives/view.js +13 -35
  22. package/dist/esm/initiatives/view.js.map +1 -1
  23. package/dist/esm/projects/HubProject.js +4 -11
  24. package/dist/esm/projects/HubProject.js.map +1 -1
  25. package/dist/esm/projects/view.js +13 -35
  26. package/dist/esm/projects/view.js.map +1 -1
  27. package/dist/esm/search/_internal/commonHelpers/getApi.js +5 -0
  28. package/dist/esm/search/_internal/commonHelpers/getApi.js.map +1 -1
  29. package/dist/esm/search/_internal/commonHelpers/getDiscussionsApiDefinition.js +10 -0
  30. package/dist/esm/search/_internal/commonHelpers/getDiscussionsApiDefinition.js.map +1 -0
  31. package/dist/esm/search/_internal/commonHelpers/shouldUseDiscussionsApi.js +13 -0
  32. package/dist/esm/search/_internal/commonHelpers/shouldUseDiscussionsApi.js.map +1 -0
  33. package/dist/esm/search/_internal/hubSearchChannels.js +116 -0
  34. package/dist/esm/search/_internal/hubSearchChannels.js.map +1 -0
  35. package/dist/esm/search/_internal/index.js +1 -0
  36. package/dist/esm/search/_internal/index.js.map +1 -1
  37. package/dist/esm/search/hubSearch.js +2 -1
  38. package/dist/esm/search/hubSearch.js.map +1 -1
  39. package/dist/esm/types.js.map +1 -1
  40. package/dist/esm/urls/getCardModelUrl.js +76 -0
  41. package/dist/esm/urls/getCardModelUrl.js.map +1 -0
  42. package/dist/esm/urls/index.js +3 -0
  43. package/dist/esm/urls/index.js.map +1 -1
  44. package/dist/node/core/types/index.js +1 -0
  45. package/dist/node/core/types/index.js.map +1 -1
  46. package/dist/node/discussions/api/channels/channels.js +18 -0
  47. package/dist/node/discussions/api/channels/channels.js.map +1 -0
  48. package/dist/node/discussions/api/channels/index.js +5 -0
  49. package/dist/node/discussions/api/channels/index.js.map +1 -0
  50. package/dist/node/discussions/api/index.js +6 -0
  51. package/dist/node/discussions/api/index.js.map +1 -0
  52. package/dist/node/discussions/api/request.js +24 -0
  53. package/dist/node/discussions/api/request.js.map +1 -0
  54. package/dist/node/discussions/api/types.js +247 -0
  55. package/dist/node/discussions/api/types.js.map +1 -0
  56. package/dist/node/discussions/api/utils/request.js +83 -0
  57. package/dist/node/discussions/api/utils/request.js.map +1 -0
  58. package/dist/node/discussions/index.js +1 -0
  59. package/dist/node/discussions/index.js.map +1 -1
  60. package/dist/node/index.js +3 -0
  61. package/dist/node/index.js.map +1 -1
  62. package/dist/node/initiatives/HubInitiative.js +4 -11
  63. package/dist/node/initiatives/HubInitiative.js.map +1 -1
  64. package/dist/node/initiatives/view.js +13 -35
  65. package/dist/node/initiatives/view.js.map +1 -1
  66. package/dist/node/projects/HubProject.js +3 -10
  67. package/dist/node/projects/HubProject.js.map +1 -1
  68. package/dist/node/projects/view.js +13 -35
  69. package/dist/node/projects/view.js.map +1 -1
  70. package/dist/node/search/_internal/commonHelpers/getApi.js +5 -0
  71. package/dist/node/search/_internal/commonHelpers/getApi.js.map +1 -1
  72. package/dist/node/search/_internal/commonHelpers/getDiscussionsApiDefinition.js +14 -0
  73. package/dist/node/search/_internal/commonHelpers/getDiscussionsApiDefinition.js.map +1 -0
  74. package/dist/node/search/_internal/commonHelpers/shouldUseDiscussionsApi.js +17 -0
  75. package/dist/node/search/_internal/commonHelpers/shouldUseDiscussionsApi.js.map +1 -0
  76. package/dist/node/search/_internal/hubSearchChannels.js +119 -0
  77. package/dist/node/search/_internal/hubSearchChannels.js.map +1 -0
  78. package/dist/node/search/_internal/index.js +1 -0
  79. package/dist/node/search/_internal/index.js.map +1 -1
  80. package/dist/node/search/hubSearch.js +1 -0
  81. package/dist/node/search/hubSearch.js.map +1 -1
  82. package/dist/node/types.js.map +1 -1
  83. package/dist/node/urls/getCardModelUrl.js +81 -0
  84. package/dist/node/urls/getCardModelUrl.js.map +1 -0
  85. package/dist/node/urls/index.js +3 -0
  86. package/dist/node/urls/index.js.map +1 -1
  87. package/dist/types/core/behaviors/IWithCardBehavior.d.ts +3 -10
  88. package/dist/types/core/types/IHubCardViewModel.d.ts +16 -0
  89. package/dist/types/core/types/index.d.ts +1 -0
  90. package/dist/types/discussions/api/channels/channels.d.ts +10 -0
  91. package/dist/types/discussions/api/channels/index.d.ts +1 -0
  92. package/dist/types/discussions/api/index.d.ts +2 -0
  93. package/dist/types/discussions/api/request.d.ts +11 -0
  94. package/dist/types/discussions/api/types.d.ts +986 -0
  95. package/dist/types/discussions/api/utils/request.d.ts +25 -0
  96. package/dist/types/discussions/index.d.ts +1 -0
  97. package/dist/types/index.d.ts +1 -0
  98. package/dist/types/initiatives/HubInitiative.d.ts +6 -13
  99. package/dist/types/initiatives/view.d.ts +5 -10
  100. package/dist/types/projects/HubProject.d.ts +3 -10
  101. package/dist/types/projects/view.d.ts +5 -10
  102. package/dist/types/search/_internal/commonHelpers/getDiscussionsApiDefinition.d.ts +2 -0
  103. package/dist/types/search/_internal/commonHelpers/shouldUseDiscussionsApi.d.ts +11 -0
  104. package/dist/types/search/_internal/hubSearchChannels.d.ts +30 -0
  105. package/dist/types/search/_internal/index.d.ts +1 -0
  106. package/dist/types/search/types/IHubCatalog.d.ts +1 -1
  107. package/dist/types/types.d.ts +1 -1
  108. package/dist/types/urls/getCardModelUrl.d.ts +21 -0
  109. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ import { RemoteServerError as _RemoteServerError } from "../../../request";
2
+ import { IDiscussionsRequestOptions } from "../types";
3
+ export declare class RemoteServerError extends _RemoteServerError {
4
+ error: string;
5
+ constructor(message: string, url: string, status: number, error: string);
6
+ }
7
+ /**
8
+ * returns Promise that resolves token to use in Discussions API requests
9
+ *
10
+ * @export
11
+ * @param {IDiscussionsRequestOptions} options
12
+ * @return {*} {Promise<string>}
13
+ */
14
+ export declare function authenticateRequest(options: IDiscussionsRequestOptions): Promise<string>;
15
+ /**
16
+ * parses IDiscussionsRequestOptions and makes request against Discussions API
17
+ *
18
+ * @export
19
+ * @template T
20
+ * @param {string} route
21
+ * @param {IDiscussionsRequestOptions} options
22
+ * @param {string} [token]
23
+ * @return {*} {Promise<T>}
24
+ */
25
+ export declare function apiRequest<T>(route: string, options: IDiscussionsRequestOptions, token?: string): Promise<T>;
@@ -3,3 +3,4 @@ export * from "./edit";
3
3
  export * from "./fetch";
4
4
  export * from "./constants";
5
5
  export * from "./utils";
6
+ export * from "./api";
@@ -33,6 +33,7 @@ export * from "./utils";
33
33
  export * from "./versioning";
34
34
  export * from "./metrics";
35
35
  export * from "./core/updateHubEntity";
36
+ export * from "./urls/getCardModelUrl";
36
37
  import OperationStack from "./OperationStack";
37
38
  import OperationError from "./OperationError";
38
39
  import HubError from "./HubError";
@@ -1,14 +1,14 @@
1
- import { IHubInitiative, IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior, UiSchemaElementOptions, IEditorConfig, IResolvedMetric } from "../core";
1
+ import { IHubInitiative, IWithCatalogBehavior, IWithStoreBehavior, IWithSharingBehavior, UiSchemaElementOptions, IEditorConfig, IResolvedMetric, IWithCardBehavior } from "../core";
2
2
  import { Catalog } from "../search";
3
3
  import { IArcGISContext } from "../ArcGISContext";
4
4
  import { HubItemEntity } from "../core/HubItemEntity";
5
5
  import { InitiativeEditorType } from "./_internal/InitiativeSchema";
6
6
  import { IWithMetricsBehavior } from "../core/behaviors/IWithMetricsBehavior";
7
- import { ICardActionLink, IHubCardViewModel } from "../core/types/IHubCardViewModel";
7
+ import { IConvertToCardModelOpts, IHubCardViewModel } from "../core/types/IHubCardViewModel";
8
8
  /**
9
9
  * Hub Initiative Class
10
10
  */
11
- export declare class HubInitiative extends HubItemEntity<IHubInitiative> implements IWithStoreBehavior<IHubInitiative>, IWithCatalogBehavior, IWithMetricsBehavior, IWithSharingBehavior {
11
+ export declare class HubInitiative extends HubItemEntity<IHubInitiative> implements IWithStoreBehavior<IHubInitiative>, IWithCatalogBehavior, IWithMetricsBehavior, IWithSharingBehavior, IWithCardBehavior {
12
12
  private _catalog;
13
13
  /**
14
14
  * Private constructor so we don't have `new` all over the place. Allows for
@@ -80,16 +80,9 @@ export declare class HubInitiative extends HubItemEntity<IHubInitiative> impleme
80
80
  resolveMetric(metricId: string): Promise<IResolvedMetric>;
81
81
  /**
82
82
  * Convert the initiative entity into a card view model that
83
- * can be consumed by the suit of hub gallery components
83
+ * can be consumed by the suite of hub gallery components
84
84
  *
85
- * @param target card link contextual target
86
- * @param actionLinks card action links
87
- * @param locale internationalization locale
85
+ * @param opts view model options
88
86
  */
89
- convertToCardViewModel(target: "ago" | "view" | "workspace", actionLinks: ICardActionLink[],
90
- /**
91
- * TODO: move transform logic to FE so we don't need to pass
92
- * locale down (follow https://devtopia.esri.com/dc/hub/issues/7255)
93
- */
94
- locale: string): IHubCardViewModel;
87
+ convertToCardModel(opts?: IConvertToCardModelOpts): IHubCardViewModel;
95
88
  }
@@ -1,24 +1,19 @@
1
- import { IArcGISContext, IHubSearchResult } from "..";
2
1
  import { IHubInitiative } from "../core";
3
- import { ICardActionLink, IHubCardViewModel } from "../core/types/IHubCardViewModel";
2
+ import { EntityToCardModelFn, ResultToCardModelFn } from "../core/types/IHubCardViewModel";
4
3
  /**
5
4
  * Convert an initiative entity in a card view model
6
5
  * that can be consumed by the suite of hub gallery components
7
6
  *
8
7
  * @param initiative initiative entity
9
8
  * @param context auth & portal information
10
- * @param target card link contextual target
11
- * @param actionLinks card action links
12
- * @param locale internationalization locale
9
+ * @param opts view model options
13
10
  */
14
- export declare const convertInitiativeEntityToCardViewModel: (initiative: IHubInitiative, context: IArcGISContext, target?: "ago" | "view" | "workspace", actionLinks?: ICardActionLink[], locale?: string) => IHubCardViewModel;
11
+ export declare const initiativeToCardModel: EntityToCardModelFn<IHubInitiative>;
15
12
  /**
16
13
  * Conver an initiative search result into a card view model
17
14
  * that can be consumed by the suite of hub gallery components
18
15
  *
19
16
  * @param searchResult hub initiative search result
20
- * @param target card link contextual target
21
- * @param actionLinks card action links
22
- * @param locale internationalization locale
17
+ * @param opts view model options
23
18
  */
24
- export declare const convertInitiativeSearchResultToCardViewModel: (searchResult: IHubSearchResult, target?: "ago" | "view" | "workspace", actionLinks?: ICardActionLink[], locale?: string) => IHubCardViewModel;
19
+ export declare const initiativeResultToCardModel: ResultToCardModelFn;
@@ -5,7 +5,7 @@ import { HubItemEntity } from "../core/HubItemEntity";
5
5
  import { IEditorConfig } from "../core/behaviors/IWithEditorBehavior";
6
6
  import { ProjectEditorType } from "./_internal/ProjectSchema";
7
7
  import { IWithMetricsBehavior } from "../core/behaviors/IWithMetricsBehavior";
8
- import { ICardActionLink, IHubCardViewModel } from "../core/types/IHubCardViewModel";
8
+ import { IConvertToCardModelOpts, IHubCardViewModel } from "../core/types/IHubCardViewModel";
9
9
  /**
10
10
  * Hub Project Class
11
11
  */
@@ -60,16 +60,9 @@ export declare class HubProject extends HubItemEntity<IHubProject> implements IW
60
60
  * Convert the project entity into a card view model that can
61
61
  * be consumed by the suite of hub gallery components
62
62
  *
63
- * @param target card link contextual target
64
- * @param actionLinks card action links
65
- * @param locale internationalization locale
63
+ * @param opts view model options
66
64
  */
67
- convertToCardViewModel(target: "ago" | "view" | "workspace", actionLinks: ICardActionLink[],
68
- /**
69
- * TODO: move transform logic to FE so we don't need to pass
70
- * locale down (follow https://devtopia.esri.com/dc/hub/issues/7255)
71
- */
72
- locale: string): IHubCardViewModel;
65
+ convertToCardModel(opts?: IConvertToCardModelOpts): IHubCardViewModel;
73
66
  /**
74
67
  * Apply a new state to the instance
75
68
  * @param changes
@@ -1,24 +1,19 @@
1
- import { IArcGISContext, IHubSearchResult } from "..";
2
1
  import { IHubProject } from "../core";
3
- import { ICardActionLink, IHubCardViewModel } from "../core/types/IHubCardViewModel";
2
+ import { ResultToCardModelFn, EntityToCardModelFn } from "../core/types/IHubCardViewModel";
4
3
  /**
5
4
  * Convert a project entity into a card view model that can
6
5
  * be consumed by the suite of hub gallery components
7
6
  *
8
7
  * @param project project entity
9
8
  * @param context auth & portal information
10
- * @param target card link contextual target
11
- * @param actionLinks card action links
12
- * @param locale internationalization locale
9
+ * @param opts view model options
13
10
  */
14
- export declare const convertProjectEntityToCardViewModel: (project: IHubProject, context: IArcGISContext, target?: "ago" | "view" | "workspace", actionLinks?: ICardActionLink[], locale?: string) => IHubCardViewModel;
11
+ export declare const projectToCardModel: EntityToCardModelFn<IHubProject>;
15
12
  /**
16
13
  * Convert a project hub search result into a card view model that
17
14
  * can be consumed by the suite of hub gallery components
18
15
  *
19
16
  * @param searchResult hub project search result
20
- * @param target card link contextual target
21
- * @param actionLinks card action links
22
- * @param locale internationalization locale
17
+ * @param opts view model options
23
18
  */
24
- export declare const convertProjectSearchResultToCardViewModel: (searchResult: IHubSearchResult, target?: "ago" | "view" | "workspace", actionLinks?: ICardActionLink[], locale?: string) => IHubCardViewModel;
19
+ export declare const projectResultToCardModel: ResultToCardModelFn;
@@ -0,0 +1,2 @@
1
+ import { IApiDefinition } from "../../types/types";
2
+ export declare function getDiscussionsApiDefinition(): IApiDefinition;
@@ -0,0 +1,11 @@
1
+ import { EntityType } from "../../types/IHubCatalog";
2
+ import { IHubSearchOptions } from "../../types/IHubSearchOptions";
3
+ /**
4
+ * @private
5
+ * Determines if the Discussions API can be targeted with the given
6
+ * search parameters
7
+ * @param targetEntity
8
+ * @param options
9
+ * @returns boolean
10
+ */
11
+ export declare function shouldUseDiscussionsApi(targetEntity: EntityType, options: IHubSearchOptions): boolean;
@@ -0,0 +1,30 @@
1
+ import { IHubSearchOptions, IHubSearchResponse, IHubSearchResult, IQuery } from "../types";
2
+ import { IChannel, IPagedResponse, ISearchChannelsParams } from "../../discussions";
3
+ /**
4
+ * @private
5
+ * Convert hubSearch IHubSearchOptions and IQuery interfaces to a
6
+ * ISearchChannelsParams structure that is needed for the Discussions API
7
+ * searchChannels(searchOptions: ISearchCHannelsParams) function
8
+ * @param {IHubSearchOptions} options
9
+ * @param {IQuery} query
10
+ * @returns ISearchChannelParams
11
+ */
12
+ export declare const processSearchParams: (options: IHubSearchOptions, query: IQuery) => ISearchChannelsParams;
13
+ /**
14
+ * @private
15
+ * Convert the Discussions API searchChannels response into an
16
+ * IHubSearchResponse necessary for supporting hubSearch results
17
+ * @param {IPagedResponse{IChannel}} channelsResponse
18
+ * @param {IQuery} query
19
+ * @param {IHubSearchOptions} options
20
+ * @returns IHubSearchResponse<IHubSearchResult>
21
+ */
22
+ export declare const toHubSearchResult: (channelsResponse: IPagedResponse<IChannel>, query: IQuery, options: IHubSearchOptions) => IHubSearchResponse<IHubSearchResult>;
23
+ /**
24
+ * @private
25
+ * Execute channel search against the Discussions API
26
+ * @param query
27
+ * @param options
28
+ * @returns
29
+ */
30
+ export declare const hubSearchChannels: (query: IQuery, options: IHubSearchOptions) => Promise<IHubSearchResponse<IHubSearchResult>>;
@@ -2,3 +2,4 @@ export * from "./portalSearchItems";
2
2
  export * from "./hubSearchItems";
3
3
  export * from "./portalSearchGroups";
4
4
  export * from "./portalSearchUsers";
5
+ export * from "./hubSearchChannels";
@@ -50,6 +50,7 @@ export interface IHubCollection {
50
50
  */
51
51
  targetEntity: EntityType;
52
52
  }
53
+ export declare type EntityType = "item" | "group" | "user" | "groupMember" | "event" | "channel";
53
54
  /**
54
55
  * @private
55
56
  *
@@ -60,7 +61,6 @@ export interface IHubCollection {
60
61
  export interface IHubCollectionPersistance extends IHubCollection {
61
62
  hidden?: boolean;
62
63
  }
63
- export declare type EntityType = "item" | "group" | "user" | "groupMember" | "event";
64
64
  /**
65
65
  * IQuery is the fundamental unit used to execute a search. By composing
66
66
  * `Filter`'s and `IPredicate`s, we can express very complex queries
@@ -130,7 +130,7 @@ export interface IRevertableTaskFailed {
130
130
  error: Error;
131
131
  }
132
132
  export declare type IRevertableTaskResult = IRevertableTaskSuccess | IRevertableTaskFailed;
133
- export declare type HubFamily = "app" | "content" | "dataset" | "document" | "event" | "feedback" | "initiative" | "map" | "people" | "site" | "team" | "template" | "project";
133
+ export declare type HubFamily = "app" | "content" | "dataset" | "document" | "event" | "feedback" | "initiative" | "map" | "people" | "site" | "team" | "template" | "project" | "channel";
134
134
  /**
135
135
  * Visibility levels of a Hub resource
136
136
  */
@@ -0,0 +1,21 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ import { HubEntity } from "../core/types/HubEntity";
3
+ import { CardModelTarget } from "../core/types/IHubCardViewModel";
4
+ import { IHubSearchResult } from "../search/types/IHubSearchResult";
5
+ /**
6
+ * returns a gallery card's title url from a hub search result
7
+ *
8
+ * @param result hub search result
9
+ * @param target context the card should redirect to
10
+ * @param baseUrl base url to work in conjunction with the target
11
+ */
12
+ export declare function getCardModelUrlFromResult(result: IHubSearchResult, target: CardModelTarget, baseUrl?: string): string;
13
+ /**
14
+ * returns a gallery card's title url from an entity
15
+ *
16
+ * @param entity hub entity
17
+ * @param context auth & portal information
18
+ * @param target context the card should redirect to
19
+ * @param baseUrl base url to work in conjunction with the target
20
+ */
21
+ export declare function getCardModelUrlFromEntity(entity: HubEntity, context: IArcGISContext, target: CardModelTarget, baseUrl?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "13.21.0",
3
+ "version": "13.22.0",
4
4
  "description": "Common TypeScript types and utility functions for @esri/hub.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/esm/index.js",