@esri/hub-common 14.47.0 → 14.48.1

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 (70) hide show
  1. package/dist/esm/core/EntityEditor.js +2 -2
  2. package/dist/esm/core/EntityEditor.js.map +1 -1
  3. package/dist/esm/core/schemas/internal/getCardEditorSchemas.js +2 -2
  4. package/dist/esm/core/schemas/internal/getCardEditorSchemas.js.map +1 -1
  5. package/dist/esm/core/schemas/internal/getEditorSchemas.js +1 -0
  6. package/dist/esm/core/schemas/internal/getEditorSchemas.js.map +1 -1
  7. package/dist/esm/core/schemas/internal/metrics/MetricSchema.js +1 -1
  8. package/dist/esm/core/schemas/internal/metrics/MetricSchema.js.map +1 -1
  9. package/dist/esm/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js +31 -0
  10. package/dist/esm/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js.map +1 -0
  11. package/dist/esm/core/schemas/internal/metrics/editorToMetric.js +121 -0
  12. package/dist/esm/core/schemas/internal/metrics/editorToMetric.js.map +1 -0
  13. package/dist/esm/core/schemas/internal/metrics/metricToEditor.js +22 -0
  14. package/dist/esm/core/schemas/internal/metrics/metricToEditor.js.map +1 -0
  15. package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js +29 -0
  16. package/dist/esm/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -0
  17. package/dist/esm/core/schemas/shared/enums.js +34 -0
  18. package/dist/esm/core/schemas/shared/enums.js.map +1 -0
  19. package/dist/esm/core/schemas/types.js +0 -18
  20. package/dist/esm/core/schemas/types.js.map +1 -1
  21. package/dist/esm/core/types/Metrics.js +12 -0
  22. package/dist/esm/core/types/Metrics.js.map +1 -1
  23. package/dist/esm/projects/HubProject.js +24 -2
  24. package/dist/esm/projects/HubProject.js.map +1 -1
  25. package/dist/esm/projects/_internal/ProjectSchema.js +3 -1
  26. package/dist/esm/projects/_internal/ProjectSchema.js.map +1 -1
  27. package/dist/esm/search/upgradeCatalogSchema.js +1 -0
  28. package/dist/esm/search/upgradeCatalogSchema.js.map +1 -1
  29. package/dist/node/core/EntityEditor.js +2 -2
  30. package/dist/node/core/EntityEditor.js.map +1 -1
  31. package/dist/node/core/schemas/internal/getCardEditorSchemas.js +2 -2
  32. package/dist/node/core/schemas/internal/getCardEditorSchemas.js.map +1 -1
  33. package/dist/node/core/schemas/internal/getEditorSchemas.js +1 -0
  34. package/dist/node/core/schemas/internal/getEditorSchemas.js.map +1 -1
  35. package/dist/node/core/schemas/internal/metrics/MetricSchema.js +4 -4
  36. package/dist/node/core/schemas/internal/metrics/MetricSchema.js.map +1 -1
  37. package/dist/node/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js +34 -0
  38. package/dist/node/core/schemas/internal/metrics/ProjectUiSchemaMetrics.js.map +1 -0
  39. package/dist/node/core/schemas/internal/metrics/editorToMetric.js +126 -0
  40. package/dist/node/core/schemas/internal/metrics/editorToMetric.js.map +1 -0
  41. package/dist/node/core/schemas/internal/metrics/metricToEditor.js +26 -0
  42. package/dist/node/core/schemas/internal/metrics/metricToEditor.js.map +1 -0
  43. package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js +33 -0
  44. package/dist/node/core/schemas/internal/metrics/setMetricAndDisplay.js.map +1 -0
  45. package/dist/node/core/schemas/shared/enums.js +37 -0
  46. package/dist/node/core/schemas/shared/enums.js.map +1 -0
  47. package/dist/node/core/schemas/types.js +1 -19
  48. package/dist/node/core/schemas/types.js.map +1 -1
  49. package/dist/node/core/types/Metrics.js +13 -0
  50. package/dist/node/core/types/Metrics.js.map +1 -1
  51. package/dist/node/projects/HubProject.js +23 -1
  52. package/dist/node/projects/HubProject.js.map +1 -1
  53. package/dist/node/projects/_internal/ProjectSchema.js +3 -1
  54. package/dist/node/projects/_internal/ProjectSchema.js.map +1 -1
  55. package/dist/node/search/upgradeCatalogSchema.js +1 -0
  56. package/dist/node/search/upgradeCatalogSchema.js.map +1 -1
  57. package/dist/types/core/EntityEditor.d.ts +1 -1
  58. package/dist/types/core/behaviors/IWithEditorBehavior.d.ts +3 -2
  59. package/dist/types/core/schemas/internal/metrics/ProjectUiSchemaMetrics.d.ts +12 -0
  60. package/dist/types/core/schemas/internal/metrics/editorToMetric.d.ts +26 -0
  61. package/dist/types/core/schemas/internal/metrics/metricToEditor.d.ts +8 -0
  62. package/dist/types/core/schemas/internal/metrics/setMetricAndDisplay.d.ts +13 -0
  63. package/dist/types/core/schemas/shared/enums.d.ts +30 -0
  64. package/dist/types/core/schemas/types.d.ts +2 -17
  65. package/dist/types/core/types/HubEntityEditor.d.ts +1 -0
  66. package/dist/types/core/types/IHubItemEntity.d.ts +2 -0
  67. package/dist/types/core/types/Metrics.d.ts +55 -2
  68. package/dist/types/projects/HubProject.d.ts +1 -1
  69. package/dist/types/projects/_internal/ProjectSchema.d.ts +1 -1
  70. package/package.json +1 -1
@@ -0,0 +1,26 @@
1
+ import { IMetric, IMetricDisplayConfig, IEntityInfo, IExpression, IMetricEditorValues } from "../../../types/Metrics";
2
+ /**
3
+ * Transforms the IConfigurationValues into an object with IMetric and IMetricDisplayConfig to be saved on an entity or rendered in the ui.
4
+ * @param values IConfigurationValues for the arcgis-hub-metric-card to use
5
+ * @param metricId what should be the id of the transformed metric
6
+ * @param entityInfo what should be the entityInfo of the transformed metric
7
+ * @returns IMetricCardParams
8
+ */
9
+ export declare function editorToMetric(values: IMetricEditorValues, metricId: string, opts?: {
10
+ metricName?: string;
11
+ entityInfo?: IEntityInfo;
12
+ }): {
13
+ metric: IMetric;
14
+ displayConfig: IMetricDisplayConfig;
15
+ };
16
+ /**
17
+ * Constructs a where clause from a given expression set.
18
+ *
19
+ * @param {Array} fields the available fields for a given dataset
20
+ * @param {Object} values the selected values
21
+ *
22
+ * @returns {string} returns a string for the where clause query
23
+ *
24
+ * NOTE: currently returns string as a MATCH and everything else as BETWEEN
25
+ */
26
+ export declare function buildWhereClause(expressionSet?: IExpression[]): string;
@@ -0,0 +1,8 @@
1
+ import { IMetric, IMetricDisplayConfig, IMetricEditorValues } from "../../../types/Metrics";
2
+ /**
3
+ * Util to convert a metric into editor values consumable by the configuration editor
4
+ * @param metric - IMetric metric
5
+ * @param displayConfig - display configuration for the metric
6
+ * @returns
7
+ */
8
+ export declare function metricToEditor(metric: IMetric, displayConfig: IMetricDisplayConfig): IMetricEditorValues;
@@ -0,0 +1,13 @@
1
+ import { IHubProject } from "../../../types/IHubProject";
2
+ import { IMetric, IMetricDisplayConfig } from "../../../types/Metrics";
3
+ /**
4
+ * Sets a given metric and metricDisplayConfig on an entity's metric and view.metricDisplays props.
5
+ *
6
+ * @param entity - should have metric and metricDisplays implemented
7
+ * @param metric - IMetric
8
+ * @param displayConfig - IMetricDisplayConfig configuration to display the metric in the ui
9
+ *
10
+ * Right now, this just accepts a HubProject; in the future as more entities support metrics,
11
+ * other entities can be allowed.
12
+ */
13
+ export declare function setMetricAndDisplay(entity: IHubProject, metric: IMetric, displayConfig: IMetricDisplayConfig): IHubProject;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Alignment values allowed for a display
3
+ *
4
+ * values = start | center | end
5
+ */
6
+ export declare enum ALIGNMENTS {
7
+ start = "start",
8
+ center = "center",
9
+ end = "end"
10
+ }
11
+ /**
12
+ * Corner values allowed for a display
13
+ *
14
+ * values = square | round
15
+ */
16
+ export declare enum CORNERS {
17
+ square = "square",
18
+ round = "round"
19
+ }
20
+ /**
21
+ * Drop shadow values allowed for a display
22
+ *
23
+ * values = none | low | medium | heavy
24
+ */
25
+ export declare enum DROP_SHADOWS {
26
+ none = "none",
27
+ low = "low",
28
+ medium = "medium",
29
+ heavy = "heavy"
30
+ }
@@ -9,7 +9,7 @@ export interface IEditorConfig {
9
9
  * to the supported/defined uiSchema configurations
10
10
  */
11
11
  export declare type EntityEditorType = (typeof validEntityEditorTypes)[number];
12
- export declare const validEntityEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit"];
12
+ export declare const validEntityEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit"];
13
13
  /** Defines the possible editor type values for a stat card. These
14
14
  * correspond to the supported/defined uiSchema configurations. This should
15
15
  * have its own signature in the getEditorConfig function.
@@ -27,7 +27,7 @@ export declare const validCardEditorTypes: readonly ["hub:card:stat"];
27
27
  * to defined schema/uiSchema configurations
28
28
  */
29
29
  export declare type EditorType = (typeof validEditorTypes)[number];
30
- export declare const validEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit", "hub:card:stat"];
30
+ export declare const validEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics", "hub:content:edit", "hub:content:settings", "hub:content:discussions", "hub:initiative:edit", "hub:initiative:create", "hub:site:edit", "hub:site:create", "hub:site:followers", "hub:site:discussions", "hub:site:settings", "hub:discussion:edit", "hub:discussion:create", "hub:discussion:settings", "hub:page:edit", "hub:template:edit", "hub:group:edit", "hub:group:settings", "hub:group:discussions", "hub:initiativeTemplate:edit", "hub:card:stat"];
31
31
  export declare enum UiSchemaRuleEffects {
32
32
  SHOW = "SHOW",
33
33
  HIDE = "HIDE",
@@ -131,18 +131,3 @@ export interface IUiSchemaCondition {
131
131
  scope?: string;
132
132
  schema: IConfigurationSchema;
133
133
  }
134
- export declare enum ALIGNMENTS {
135
- start = "start",
136
- center = "center",
137
- end = "end"
138
- }
139
- export declare enum CORNERS {
140
- square = "square",
141
- round = "round"
142
- }
143
- export declare enum DROP_SHADOWS {
144
- none = "none",
145
- low = "low",
146
- medium = "medium",
147
- heavy = "heavy"
148
- }
@@ -8,4 +8,5 @@ export declare type HubEntityEditor = Record<string, any>;
8
8
  export interface IEntityEditorContext {
9
9
  collaborationGroupId?: string;
10
10
  contentGroupId?: string;
11
+ metricId?: string;
11
12
  }
@@ -5,6 +5,7 @@ import { IWithPermissions, IWithViewSettings, IWithDiscussions } from "../traits
5
5
  import { IHubLocation } from "./IHubLocation";
6
6
  import { IWithFollowers } from "../traits/IWithFollowers";
7
7
  import { IWithAssociations } from "../traits/IWithAssociations";
8
+ import { IMetricEditorValues } from "./Metrics";
8
9
  /**
9
10
  * Properties exposed by Entities that are backed by Items
10
11
  */
@@ -122,4 +123,5 @@ export declare type IHubItemEntityEditor<T> = Omit<T, "extent"> & {
122
123
  showFollowAction?: boolean;
123
124
  isDiscussable?: boolean;
124
125
  };
126
+ _metric?: IMetricEditorValues;
125
127
  };
@@ -1,8 +1,8 @@
1
1
  /// <reference types="arcgis-js-api" />
2
2
  import { IQuery } from "../../search/types/IHubCatalog";
3
- import { IField } from "@esri/arcgis-rest-types";
4
- import { ServiceAggregation } from "./DynamicValues";
3
+ import { FieldType, IField } from "@esri/arcgis-rest-types";
5
4
  import { IReference } from "./IReference";
5
+ import { ServiceAggregation } from "../../core/types/DynamicValues";
6
6
  /**
7
7
  * Defines the information required from a Metric
8
8
  */
@@ -182,6 +182,20 @@ export interface IExpression {
182
182
  * A special identifier given to the expression when it is created
183
183
  */
184
184
  key?: string;
185
+ /**
186
+ * Relation between the values in an expression
187
+ */
188
+ relationship?: ExpressionRelationships;
189
+ }
190
+ /**
191
+ * Possible relationships for an expression
192
+ * BETWEEN -- used to show between two values, i.e. 7 < x < 10
193
+ * IS_EXACTLY -- for exact matching, i.e. two same strings
194
+ */
195
+ export declare enum ExpressionRelationships {
196
+ BETWEEN = "between",
197
+ IS_EXACTLY = "isExactly",
198
+ LIKE = "like"
185
199
  }
186
200
  /**
187
201
  * Configuration for how to show a metric in the ui
@@ -191,3 +205,42 @@ export interface IMetricDisplayConfig {
191
205
  displayType: string;
192
206
  [key: string]: any;
193
207
  }
208
+ /**
209
+ * Editor values expected when editing a metric
210
+ */
211
+ export interface IMetricEditorValues extends IMetricDisplayConfig {
212
+ /** the main value of the metric */
213
+ value?: string | number;
214
+ /** all values related to constructing a service-query metric */
215
+ dynamicMetric?: IDynamicMetricValues;
216
+ }
217
+ /**
218
+ * Editor values associated with editing a dynamic metric
219
+ */
220
+ export interface IDynamicMetricValues {
221
+ /** id of the item being queried */
222
+ itemId?: string;
223
+ /** id of the layer of the item being queried */
224
+ layerId?: number;
225
+ /** field of the layer of the item being queried to run the aggregation on */
226
+ field?: string;
227
+ /** the method of service aggregation -- count, min, max, etc. */
228
+ statistic?: string;
229
+ /** the feature service url of the item being queried */
230
+ serviceUrl?: string;
231
+ /** the esri-dictated field type of the field being queried */
232
+ fieldType?: FieldType;
233
+ /** a clause to filter the query by -- ex: field BETWEEN 0 AND 2 */
234
+ where?: string;
235
+ /** the ui navigational link to the item source */
236
+ sourceLink?: string;
237
+ /** the text displayed in the ui for the sourceLink */
238
+ sourceTitle?: string;
239
+ /** whether attribute filtering should be enabled */
240
+ allowExpressionSet?: boolean;
241
+ /** a list of expressions with which to construct a where clause */
242
+ expressionSet?: IExpression[];
243
+ /** the old where clause, utilized during the migration of the old summary stat card */
244
+ legacyWhere?: string;
245
+ [key: string]: any;
246
+ }
@@ -71,7 +71,7 @@ export declare class HubProject extends HubItemEntity<IHubProject> implements IW
71
71
  * @param editor
72
72
  * @returns
73
73
  */
74
- fromEditor(editor: IHubProjectEditor): Promise<IHubProject>;
74
+ fromEditor(editor: IHubProjectEditor, editorContext?: IEntityEditorContext): Promise<IHubProject>;
75
75
  /**
76
76
  * Apply a new state to the instance
77
77
  * @param changes
@@ -1,6 +1,6 @@
1
1
  import { IConfigurationSchema } from "../../core/schemas/types";
2
2
  export declare type ProjectEditorType = (typeof ProjectEditorTypes)[number];
3
- export declare const ProjectEditorTypes: readonly ["hub:project:create", "hub:project:edit"];
3
+ export declare const ProjectEditorTypes: readonly ["hub:project:create", "hub:project:edit", "hub:project:metrics"];
4
4
  /**
5
5
  * Defines the JSON schema for a Hub Project's editable fields
6
6
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "14.47.0",
3
+ "version": "14.48.1",
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",