@disy/cadenza.js 10.2.2 → 10.2.4

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 (55) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/apidoc/assets/navigation.js +1 -1
  3. package/apidoc/assets/search.js +1 -1
  4. package/apidoc/classes/AbortError.html +3 -3
  5. package/apidoc/classes/CadenzaClient.html +123 -38
  6. package/apidoc/classes/CadenzaError.html +5 -5
  7. package/apidoc/functions/cadenza.html +3 -3
  8. package/apidoc/index.html +2 -2
  9. package/apidoc/interfaces/CadenzaClientOptions.html +5 -5
  10. package/apidoc/interfaces/CadenzaEvent.html +4 -4
  11. package/apidoc/interfaces/Distance.html +2 -2
  12. package/apidoc/interfaces/ExternalLinkKey.html +4 -4
  13. package/apidoc/interfaces/Feature.html +11 -7
  14. package/apidoc/interfaces/FeatureCollection.html +5 -3
  15. package/apidoc/interfaces/Geometry.html +6 -4
  16. package/apidoc/interfaces/GeometryExtentStrategy.html +6 -0
  17. package/apidoc/interfaces/LayerDataExtentStrategy.html +7 -0
  18. package/apidoc/interfaces/LayerDefinition.html +7 -0
  19. package/apidoc/interfaces/LocationFinderExtentStrategy.html +6 -0
  20. package/apidoc/interfaces/PageSource.html +3 -3
  21. package/apidoc/interfaces/StaticExtentStrategy.html +6 -0
  22. package/apidoc/modules.html +9 -4
  23. package/apidoc/types/CadenzaActionEvent.html +2 -2
  24. package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
  25. package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
  26. package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
  27. package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
  28. package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
  29. package/apidoc/types/CadenzaErrorEvent.html +2 -2
  30. package/apidoc/types/CadenzaEventByType.html +1 -1
  31. package/apidoc/types/CadenzaEventType.html +2 -2
  32. package/apidoc/types/CadenzaObjectInfoEvent.html +2 -2
  33. package/apidoc/types/CadenzaReloadEvent.html +2 -2
  34. package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
  35. package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
  36. package/apidoc/types/{ZoomTarget.html → Coordinate.html} +2 -2
  37. package/apidoc/types/CustomValidityType.html +2 -2
  38. package/apidoc/types/DataType.html +2 -2
  39. package/apidoc/types/EmbeddingTargetId.html +2 -2
  40. package/apidoc/types/Extent.html +2 -2
  41. package/apidoc/types/ExtentStrategy.html +5 -0
  42. package/apidoc/types/FilterVariables.html +2 -2
  43. package/apidoc/types/GeometryType.html +2 -2
  44. package/apidoc/types/GlobalId.html +2 -2
  45. package/apidoc/types/LengthUnit.html +1 -1
  46. package/apidoc/types/OpaqueString.html +2 -2
  47. package/apidoc/types/OperationMode.html +2 -2
  48. package/apidoc/types/TablePart.html +2 -2
  49. package/apidoc/types/UiFeature.html +2 -2
  50. package/apidoc/types/WorkbookLayerPath.html +2 -2
  51. package/cadenza.d.ts +198 -130
  52. package/cadenza.js +245 -122
  53. package/package.json +1 -1
  54. package/sandbox.html +129 -41
  55. package/apidoc/interfaces/GeometryZoomTarget.html +0 -4
package/cadenza.js CHANGED
@@ -97,6 +97,12 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
97
97
  * * `"workbook-map-add-layer"`- Add layers to the map
98
98
  * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
99
99
  * */
100
+ /**
101
+ * @typedef LayerDefinition
102
+ * @property {string} name - The layer's name.
103
+ * @property {'geojson'} type - The layer's type.
104
+ * @property {FeatureCollection} content - The layer's content in geojson format.
105
+ */
100
106
  /**
101
107
  * @typedef Distance
102
108
  * @property {number} value
@@ -105,9 +111,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
105
111
  /**
106
112
  * @typedef {'m'|'km'} LengthUnit
107
113
  */
114
+ /** @typedef {[number, number]} Coordinate - A tuple with an x and y value */
108
115
  /**
109
116
  * @typedef Geometry - A [GeoJSON](https://geojson.org/) geometry object
110
117
  * @property {GeometryType} type - The type of the geometry
118
+ * @property {Coordinate | Coordinate[] | Coordinate[][] | Coordinate[][][]} coordinates - The coordinates of the geometry
111
119
  */
112
120
  /**
113
121
  * @typedef {'Point'|'MultiPoint'|'LineString'|'MultiLineString'|'Polygon'|'MultiPolygon'} GeometryType - A GeoJSON geometry type
@@ -116,11 +124,34 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
116
124
  */
117
125
  /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */
118
126
  /**
119
- * @typedef {GeometryZoomTarget} ZoomTarget - An object describing a target to zoom to
127
+ * @typedef {GeometryExtentStrategy|
128
+ * LayerDataExtentStrategy|
129
+ * LocationFinderExtentStrategy|
130
+ * StaticExtentStrategy} ExtentStrategy - Options for defining the initial extent of a workbook map view;
131
+ * If the options do not result in a defined extent, Cadenza's default logic is used:
132
+ * The map will zoom in the way the underlying workbook map view was configured to initially zoom including all auto
133
+ * zooming configurations.
134
+ */
135
+ /**
136
+ * @typedef GeometryExtentStrategy - The given {@link Geometry} defines the initial map extent.
137
+ * @property {'geometry'} type - The extent strategy type
138
+ * @property {Geometry} [geometry] - This geometry takes precedence over another geometry that might be given in an API call.
139
+ */
140
+ /**
141
+ * @typedef LayerDataExtentStrategy - The given layers define the initial map extent.
142
+ * @property {'layerData'} type - The extent strategy type
143
+ * @property {(WorkbookLayerPath | string)[]} [layers] - A layer is ignored if either the layer or its extent is not known to Cadenza.
144
+ * If no layers are given, __all__ map layers are used.
145
+ */
146
+ /**
147
+ * @typedef LocationFinderExtentStrategy - The first result of a location finder query defines the initial map extent.
148
+ * @property {'locationFinder'} type - The extent strategy type
149
+ * @property {string} query - This query takes precedence over another query that might be given in an API call.
120
150
  */
121
151
  /**
122
- * @typedef GeometryZoomTarget - Instructs Cadenza to zoom to a provided {@Link Geometry}
123
- * @property {'geometry'} type The type of the zoom target
152
+ * @typedef StaticExtentStrategy - The given extent is used as the initial map extent.
153
+ * @property {'static'} type - The extent strategy type
154
+ * @property {Extent} extent - This extent takes precedence over another extent that might be given in an API call.
124
155
  */
125
156
  /**
126
157
  * @typedef {'csv' | 'excel' | 'json' | 'pdf' | 'png'} DataType - A data type
@@ -138,14 +169,17 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
138
169
  */
139
170
  /**
140
171
  * @typedef Feature - A adapted [GeoJSON](https://geojson.org/) feature object.
172
+ * @property {'Feature'} type - The object's type
141
173
  * @property {any[]} objectId - The id of the feature
142
174
  * @property {Geometry} geometry - The geometry
143
175
  * @property {Record<string, string>} properties - The formated properties
144
176
  * @property {number} [area] - The area of a `Polygon` feature
145
- * @property {number} [length] - The area of a `LineString` feature
177
+ * @property {number} [circumference] - The circumference of a `Polygon` feature
178
+ * @property {number} [length] - The length of a `LineString` feature
146
179
  */
147
180
  /**
148
181
  * @typedef FeatureCollection - A adapted [GeoJSON](https://geojson.org/) feature collection object
182
+ * @property {'FeatureCollection'} type - The object's type
149
183
  * @property {Feature[]} features - The features within this collection
150
184
  */
151
185
  /** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */
@@ -163,7 +197,8 @@ let firstEmbeddingTargetShown;
163
197
  * When aborted, the result Promise is rejected with an {@link AbortError}.
164
198
  * * If there's another error, the result Promise is rejected with a {@link CadenzaError}.
165
199
  * * For methods that support the `hideMainHeaderAndFooter` and `hideWorkbookToolBar` parameters - the parameters cannot override the configuration of an embedding target.
166
- * * For methods that support the `locationFinder` and `mapExtent` parameters - when both are given, the `mapExtent` takes precedence.
200
+ * * For methods that support the _deprecated_ `locationFinder` and `mapExtent` parameters - when both are given, the `mapExtent` takes precedence.
201
+ * * Both `locationFinder` and `mapExtent` parameters are _deprecated_ - Use {@link LocationFinderExtentStrategy} or {@link StaticExtentStrategy} instead.
167
202
  */
168
203
  // Must be exported to be included in the docs.
169
204
  export class CadenzaClient {
@@ -184,7 +219,7 @@ export class CadenzaClient {
184
219
  /**
185
220
  *
186
221
  * @hidden
187
- * @param {CadenzaClientOptions} [options]
222
+ * @param {CadenzaClientOptions} [__namedParameters]
188
223
  */
189
224
  constructor({ baseUrl, debug = false, iframe, webApplication } = {}) {
190
225
  if (webApplication) {
@@ -241,18 +276,19 @@ export class CadenzaClient {
241
276
  * Show a page, workbook, worksheet or workbook view in an iframe.
242
277
  *
243
278
  * @param {PageSource | EmbeddingTargetId} source - The source to show
244
- * @param {object} [options]
245
- * @param {DataType} [options.dataType] - Set to 'pdf' for views of type "JasperReports report"
246
- * to show the report PDF directly, without any Cadenza headers or footers.
247
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
248
- * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
249
- * @param {FilterVariables} [options.filter] - Filter variables
250
- * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
251
- * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
252
- * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
253
- * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
254
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
255
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
279
+ * @param {object} [__namedParameters]
280
+ * @param {DataType} [__namedParameters.dataType] - Set to 'pdf' for embedding targets of type report and of views with view
281
+ * type of "JasperReports report" to show the generated report PDF directly (without any Cadenza headers or
282
+ * footers).
283
+ * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
284
+ * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
285
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
286
+ * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
287
+ * @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar
288
+ * @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
289
+ * @param {String} [__namedParameters.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
290
+ * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
291
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
256
292
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
257
293
  * @throws For invalid arguments
258
294
  * @fires
@@ -285,8 +321,8 @@ export class CadenzaClient {
285
321
  }
286
322
  /**
287
323
  * Reload the views of a worksheet.
288
- * @param {object} [options] - Options
289
- * @param {boolean} [options.invalidateCaches] - When true, caches will be invalidated for objecttypes used
324
+ * @param {object} [__namedParameters] - Options
325
+ * @param {boolean} [__namedParameters.invalidateCaches] - When true, caches will be invalidated for objecttypes used
290
326
  * in the worksheet
291
327
  * @postMessage
292
328
  */
@@ -307,20 +343,21 @@ export class CadenzaClient {
307
343
  * Show a workbook map view in an iframe.
308
344
  *
309
345
  * @param {EmbeddingTargetId} mapView - The workbook map view to show
310
- * @param {object} [options] - Options
311
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
312
- * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
313
- * @param {FilterVariables} [options.filter] - Filter variables
314
- * @param {Geometry} [options.geometry] - A geometry to show on the map
315
- * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
316
- * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
317
- * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
318
- * @param {string} [options.locationFinder] - A search query for the location finder
319
- * @param {Extent} [options.mapExtent] - A map extent to set
320
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
321
- * @param {boolean} [options.useMapSrs] - Whether the geometry and the extent are in the map's SRS (otherwise EPSG:4326 is assumed)
322
- * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
323
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
346
+ * @param {object} [__namedParameters] - Options
347
+ * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
348
+ * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
349
+ * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
350
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
351
+ * @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map
352
+ * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
353
+ * @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar
354
+ * @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
355
+ * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
356
+ * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
357
+ * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
358
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
359
+ * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
360
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
324
361
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
325
362
  * @throws For invalid arguments
326
363
  * @fires
@@ -328,12 +365,17 @@ export class CadenzaClient {
328
365
  * - {@link CadenzaActionEvent}
329
366
  * @embed
330
367
  */
331
- async showMap(mapView, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, zoomTarget, signal, } = {}) {
368
+ async showMap(mapView, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, extentStrategy, signal, additionalLayers, } = {}) {
332
369
  this.#log('CadenzaClient#showMap', ...arguments);
333
370
  if (geometry) {
334
371
  assertValidGeometryType(geometry.type);
335
372
  }
336
- const zoomToGeometry = geometry && zoomTarget?.type === 'geometry';
373
+ const validExtentStrategy = sanitizeExtentStrategy({
374
+ geometry,
375
+ locationFinder,
376
+ mapExtent,
377
+ extentStrategy,
378
+ });
337
379
  const params = createParams({
338
380
  disabledUiFeatures,
339
381
  expandNavigator,
@@ -341,21 +383,23 @@ export class CadenzaClient {
341
383
  hideMainHeaderAndFooter,
342
384
  hideWorkbookToolBar,
343
385
  highlightGlobalId,
344
- // only use locationFinder if zoom to geometry is not set, to avoid
345
- // zooming race condition for Cadenza versions below 10.1
346
- locationFinder: zoomToGeometry ? undefined : locationFinder,
347
- mapExtent,
348
386
  operationMode,
349
387
  targetType: 'MAP',
350
388
  useMapSrs,
389
+ validExtentStrategy,
351
390
  });
352
391
  await this.#show(resolvePath(mapView), params, signal);
353
392
  if (geometry) {
354
393
  this.#postEvent('setGeometry', {
355
394
  geometry,
356
- zoomToGeometry,
357
395
  });
358
396
  }
397
+ if (additionalLayers) {
398
+ for (const layer of additionalLayers) {
399
+ await this.#postRequest('importLayer', layer);
400
+ }
401
+ }
402
+ this.#setExtentStrategy(validExtentStrategy);
359
403
  }
360
404
  /**
361
405
  * Expand/collapse the navigator.
@@ -457,12 +501,6 @@ export class CadenzaClient {
457
501
  values,
458
502
  });
459
503
  }
460
- /**
461
- * @typedef {Object} LayerDefinition
462
- * @property {string} name - The layer's name.
463
- * @property {'geojson'} type - The layer's type.
464
- * @property {FeatureCollection} content - The layer's content in geojson format.
465
- */
466
504
  /**
467
505
  * Create a geometry.
468
506
  *
@@ -471,16 +509,17 @@ export class CadenzaClient {
471
509
  *
472
510
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
473
511
  * @param {GeometryType} geometryType - The geometry type
474
- * @param {object} [options] - Options
475
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
476
- * @param {FilterVariables} [options.filter] - Filter variables
477
- * @param {string} [options.locationFinder] - A search query for the location finder
478
- * @param {Extent} [options.mapExtent] - A map extent to set
479
- * @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
480
- * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used)
481
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
482
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
483
- * @param {LayerDefinition[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
512
+ * @param {object} [__namedParameters] - Options
513
+ * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
514
+ * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
515
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
516
+ * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
517
+ * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
518
+ * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
519
+ * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
520
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
521
+ * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS and the created geometry should use the map's SRS (otherwise EPSG:4326 is assumed)
522
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
484
523
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
485
524
  * @throws For invalid arguments
486
525
  * @fires
@@ -489,40 +528,47 @@ export class CadenzaClient {
489
528
  * - {@link CadenzaEditGeometryCancelEvent}
490
529
  * @embed
491
530
  */
492
- async createGeometry(backgroundMapView, geometryType, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, additionalLayers, } = {}) {
531
+ async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
493
532
  this.#log('CadenzaClient#createGeometry', ...arguments);
533
+ const validExtentStrategy = sanitizeExtentStrategy({
534
+ locationFinder,
535
+ mapExtent,
536
+ extentStrategy,
537
+ });
494
538
  const params = createParams({
495
539
  action: 'editGeometry',
496
540
  disabledUiFeatures,
497
541
  filter,
498
542
  geometryType,
499
- locationFinder,
500
- mapExtent,
501
543
  minScale,
502
- useMapSrs,
503
544
  operationMode,
545
+ useMapSrs,
546
+ validExtentStrategy,
504
547
  });
505
548
  await this.#show(resolvePath(backgroundMapView), params, signal);
506
549
  if (additionalLayers) {
507
- additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
550
+ for (const layer of additionalLayers) {
551
+ await this.#postRequest('importLayer', layer);
552
+ }
508
553
  }
554
+ this.#setExtentStrategy(validExtentStrategy);
509
555
  }
510
556
  /**
511
557
  * Edit a geometry.
512
558
  *
513
559
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
514
560
  * @param {Geometry} geometry - The geometry
515
- * @param {object} [options] - Options
516
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
517
- * @param {FilterVariables} [options.filter] - Filter variables
518
- * @param {string} [options.locationFinder] - A search query for the location finder
519
- * @param {Extent} [options.mapExtent] - A map extent to set
520
- * @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
521
- * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
522
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
523
- * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
524
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
525
- * @param {Object[]} [options.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
561
+ * @param {object} [__namedParameters] - Options
562
+ * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
563
+ * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
564
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
565
+ * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
566
+ * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
567
+ * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
568
+ * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
569
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
570
+ * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
571
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
526
572
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
527
573
  * @throws For invalid arguments
528
574
  * @fires
@@ -531,32 +577,36 @@ export class CadenzaClient {
531
577
  * - {@link CadenzaEditGeometryCancelEvent}
532
578
  * @embed
533
579
  */
534
- async editGeometry(backgroundMapView, geometry, { disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, zoomTarget, operationMode, signal, additionalLayers, } = {}) {
580
+ async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, operationMode, signal, useMapSrs, extentStrategy, } = {}) {
535
581
  this.#log('CadenzaClient#editGeometry', ...arguments);
536
582
  assertValidGeometryType(geometry.type);
537
- const zoomToGeometry = geometry && zoomTarget?.type === 'geometry';
583
+ const validExtentStrategy = sanitizeExtentStrategy({
584
+ geometry,
585
+ locationFinder,
586
+ mapExtent,
587
+ extentStrategy,
588
+ });
538
589
  const params = createParams({
539
590
  action: 'editGeometry',
540
591
  disabledUiFeatures,
541
592
  filter,
542
- // only use locationFinder if zoom to geometry is not set, to avoid
543
- // zooming race condition for Cadenza versions below 10.1
544
- locationFinder: zoomToGeometry ? undefined : locationFinder,
545
- mapExtent,
546
593
  minScale,
547
- useMapSrs,
548
594
  operationMode,
595
+ useMapSrs,
596
+ validExtentStrategy,
549
597
  });
550
598
  await this.#show(resolvePath(backgroundMapView), params, signal);
551
599
  if (geometry) {
552
600
  this.#postEvent('setGeometry', {
553
601
  geometry,
554
- zoomToGeometry,
555
602
  });
556
603
  }
557
604
  if (additionalLayers) {
558
- additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
605
+ for (const layer of additionalLayers) {
606
+ await this.#postRequest('importLayer', layer);
607
+ }
559
608
  }
609
+ this.#setExtentStrategy(validExtentStrategy);
560
610
  }
561
611
  /**
562
612
  * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
@@ -575,15 +625,16 @@ export class CadenzaClient {
575
625
  * Select objects in a workbook map.
576
626
  *
577
627
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
578
- * @param {object} [options] - Options
579
- * @param {FilterVariables} [options.filter] - Filter variables
580
- * @param {(WorkbookLayerPath | string)[]} [options.layers] - Layers to restrict the selection to
628
+ * @param {object} [__namedParameters] - Options
629
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
630
+ * @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
581
631
  * (identified using layer paths or print names)
582
- * @param {string} [options.locationFinder] - A search query for the location finder
583
- * @param {Extent} [options.mapExtent] - A map extent to set
584
- * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
585
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
586
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
632
+ * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
633
+ * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
634
+ * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
635
+ * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
636
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
637
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
587
638
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
588
639
  * @throws For invalid arguments
589
640
  * @fires
@@ -593,18 +644,31 @@ export class CadenzaClient {
593
644
  * - {@link CadenzaSelectObjectsCancelEvent}
594
645
  * @embed
595
646
  */
596
- selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, } = {}) {
647
+ async selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
597
648
  this.#log('CadenzaClient#selectObjects', ...arguments);
649
+ const validExtentStrategy = sanitizeExtentStrategy({
650
+ geometry: undefined,
651
+ locationFinder,
652
+ mapExtent,
653
+ extentStrategy,
654
+ });
598
655
  const params = createParams({
599
656
  action: 'selectObjects',
600
657
  filter,
601
658
  layers: layers?.map(array),
602
- locationFinder,
603
- mapExtent,
604
659
  useMapSrs,
605
660
  operationMode,
661
+ validExtentStrategy,
606
662
  });
607
- return this.#show(resolvePath(backgroundMapView), params, signal);
663
+ await this.#show(resolvePath(backgroundMapView), params, signal);
664
+ this.#setExtentStrategy(validExtentStrategy);
665
+ }
666
+ #setExtentStrategy(/** @type {ExtentStrategy | undefined} */ extentStrategy) {
667
+ const type = extentStrategy?.type;
668
+ // Other extent strategies are handled via URL parameters.
669
+ if (type === 'geometry' || type === 'layerData') {
670
+ this.#postEvent('setExtentStrategy', extentStrategy);
671
+ }
608
672
  }
609
673
  /**
610
674
  * @param {string} path
@@ -787,12 +851,13 @@ export class CadenzaClient {
787
851
  *
788
852
  * @param {EmbeddingTargetId} source - The workbook view to fetch data from.
789
853
  * @param {DataType} dataType - The data type you want to get back from the server.
790
- * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views
791
- * and `"pdf"` for views of type "JasperReports report".
792
- * @param {object} [options] - Options
793
- * @param {FilterVariables} [options.filter] - Filter variables
794
- * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
795
- * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
854
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
855
+ * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type
856
+ * of "JasperReports report".
857
+ * @param {object} [__namedParameters] - Options
858
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
859
+ * @param {TablePart[]} [__namedParameters.parts] - Table parts to export; If not specified, all parts are exported.
860
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
796
861
  * @return {Promise<Response>} A `Promise` for the fetch response
797
862
  * @throws For invalid arguments
798
863
  * @server
@@ -810,11 +875,11 @@ export class CadenzaClient {
810
875
  * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer
811
876
  * (identified using layer paths or print names)
812
877
  * @param {unknown[][]} objectIds - The IDs of the objects to select
813
- * @param {object} [options] - Options
814
- * @param {FilterVariables} [options.filter] - Filter variables
815
- * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
816
- * @param {Boolean} [options.useMapSrs] - Use the map SRS instead of WGS84
817
- * @param {Boolean} [options.fullGeometries] - Return non-simplified geometries
878
+ * @param {object} [__namedParameters] - Options
879
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
880
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
881
+ * @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84
882
+ * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
818
883
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
819
884
  * @throws For invalid arguments
820
885
  */
@@ -837,10 +902,10 @@ export class CadenzaClient {
837
902
  * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer
838
903
  * (identified using layer paths or print names)
839
904
  * @param {Geometry} geometry - The intersection geometry
840
- * @param {object} [options] - Options
841
- * @param {boolean} [options.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
842
- * @param {Distance} [options.buffer] - Buffer size for geometry of the transition
843
- * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
905
+ * @param {object} [__namedParameters] - Options
906
+ * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
907
+ * @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition
908
+ * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
844
909
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
845
910
  * @server
846
911
  */
@@ -890,12 +955,13 @@ export class CadenzaClient {
890
955
  *
891
956
  * @param {EmbeddingTargetId} source - The workbook view to fetch data from.
892
957
  * @param {DataType} dataType - The data type you want to get back from the server.
893
- * Currently, `"csv"`, `"excel"` and `"json"` are supported for table and indicator views
894
- * and `"pdf"` for views of type "JasperReports report".
895
- * @param {object} [options] - Options
896
- * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
897
- * @param {FilterVariables} [options.filter] - Filter variables
898
- * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
958
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
959
+ * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type
960
+ * of "JasperReports report".
961
+ * @param {object} [__namedParameters] - Options
962
+ * @param {string} [__namedParameters.fileName] - The file name to use; The file extension is appended by Cadenza.
963
+ * @param {FilterVariables} [__namedParameters.filter] - Filter variables
964
+ * @param {TablePart[]} [__namedParameters.parts] - Table parts to export; If not specified, all parts are exported.
899
965
  * @throws For invalid arguments
900
966
  * @server
901
967
  */
@@ -1039,16 +1105,15 @@ function assertSupportedDataType(
1039
1105
  * @param {GlobalId} [params.highlightGlobalId]
1040
1106
  * @param {string} [params.labelSet]
1041
1107
  * @param {WorkbookLayerPath[]} [params.layers]
1042
- * @param {string} [params.locationFinder]
1043
- * @param {Extent} [params.mapExtent]
1044
1108
  * @param {number} [params.minScale]
1045
1109
  * @param {OperationMode} [params.operationMode]
1046
1110
  * @param {TablePart[]} [params.parts]
1047
1111
  * @param {'MAP'} [params.targetType]
1048
1112
  * @param {boolean} [params.useMapSrs]
1113
+ * @param {ExtentStrategy | undefined} [params.validExtentStrategy]
1049
1114
  * @return {URLSearchParams}
1050
1115
  */
1051
- function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, locationFinder, mapExtent, minScale, operationMode, parts, targetType, useMapSrs, }) {
1116
+ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, useMapSrs, validExtentStrategy, }) {
1052
1117
  if (disabledUiFeatures) {
1053
1118
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
1054
1119
  }
@@ -1064,6 +1129,16 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1064
1129
  if (parts) {
1065
1130
  parts.forEach((part) => assert(validTablePart(part), `Invalid table part: ${part}`));
1066
1131
  }
1132
+ let locationFinder;
1133
+ let mapExtent;
1134
+ if (validExtentStrategy) {
1135
+ if (validExtentStrategy.type === 'static') {
1136
+ mapExtent = validExtentStrategy.extent;
1137
+ }
1138
+ else if (validExtentStrategy.type === 'locationFinder') {
1139
+ locationFinder = validExtentStrategy.query;
1140
+ }
1141
+ }
1067
1142
  return new URLSearchParams({
1068
1143
  ...(action && { action }),
1069
1144
  ...(dataType && { dataType }),
@@ -1098,6 +1173,54 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1098
1173
  function array(/** @type unknown */ value) {
1099
1174
  return Array.isArray(value) ? value : [value];
1100
1175
  }
1176
+ /**
1177
+ * Creates a valid extent strategy based on these rules:
1178
+ * - `extentStrategy` trumps `mapExtent`, `mapExtent` trumps `locationFinder`.
1179
+ * - `mapExtent`, `locationFinder`, and `geometry` are used as fallback for
1180
+ * {@link StaticExtentStrategy#extent}, {@link LocationFinderExtentStrategy#query},
1181
+ * and {@link GeometryExtentStrategy#geometry} respectively.
1182
+ *
1183
+ * If the result is not a valid extent strategy, the return value is undefined.
1184
+ *
1185
+ * @param {object} __namedParameters
1186
+ * @param {Geometry} [__namedParameters.geometry]
1187
+ * @param {string} [__namedParameters.locationFinder]
1188
+ * @param {Extent} [__namedParameters.mapExtent]
1189
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy]
1190
+ * @return {ExtentStrategy | undefined}
1191
+ */
1192
+ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geometry, } = {}) {
1193
+ if (extentStrategy) {
1194
+ switch (extentStrategy.type) {
1195
+ case 'static':
1196
+ const extent = extentStrategy.extent ?? mapExtent;
1197
+ if (extent) {
1198
+ return { type: 'static', extent };
1199
+ }
1200
+ break;
1201
+ case 'locationFinder':
1202
+ const query = extentStrategy.query ?? locationFinder;
1203
+ if (query) {
1204
+ return { type: 'locationFinder', query };
1205
+ }
1206
+ break;
1207
+ case 'geometry':
1208
+ geometry = extentStrategy.geometry ?? geometry;
1209
+ if (geometry) {
1210
+ return { type: 'geometry', geometry };
1211
+ }
1212
+ break;
1213
+ default:
1214
+ return extentStrategy;
1215
+ }
1216
+ }
1217
+ if (mapExtent) {
1218
+ return { type: 'static', extent: mapExtent };
1219
+ }
1220
+ if (locationFinder) {
1221
+ return { type: 'locationFinder', query: locationFinder };
1222
+ }
1223
+ }
1101
1224
  // Please do not add internal event types like 'ready' here.
1102
1225
  /**
1103
1226
  * @typedef {'action'
@@ -1143,7 +1266,7 @@ function array(/** @type unknown */ value) {
1143
1266
  * The extent is transformed according to the `useMapSrs` option.
1144
1267
  */
1145
1268
  /**
1146
- * @typedef {CadenzaEvent<'change:selection', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaChangeSelectionEvent - When the user changed the selection.
1269
+ * @typedef {CadenzaEvent<'change:selection', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaChangeSelectionEvent - When the user changed the selection. `undefined` if no objects were selected.
1147
1270
  *
1148
1271
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
1149
1272
  */
@@ -1156,13 +1279,13 @@ function array(/** @type unknown */ value) {
1156
1279
  * <p>
1157
1280
  * See also: <a href="../index.html#md:json-representation-of-cadenza-object-data">JSON Representation of Cadenza Object Data</a>
1158
1281
  */
1159
- /** @typedef {CadenzaEvent<'editGeometry:update', {geometry: Geometry}>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. */
1160
- /** @typedef {CadenzaEvent<'editGeometry:ok', {geometry: Geometry}>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
1282
+ /** @typedef {CadenzaEvent<'editGeometry:update', FeatureCollection | Feature | undefined>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. `FeatureCollection` if multiple features are present on the edit layer, but the original defined type is not multi-geometry. This is also the case if the dialog was instantiated from a geometry and the original defined type is inherited. `undefined` if no feature is present on the edit layer. */
1283
+ /** @typedef {CadenzaEvent<'editGeometry:ok', Feature>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
1161
1284
  /** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
1162
1285
  /** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
1163
1286
  /** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number, elements: {attributePrintName: string, formattedValue: string}[]}}>} CadenzaObjectInfoEvent - When the user opened the object info flyout. */
1164
1287
  /**
1165
- * @typedef {CadenzaEvent<'selectObjects:ok', {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection.
1288
+ * @typedef {CadenzaEvent<'selectObjects:ok', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection. `undefined` if no objects were selected.
1166
1289
  *
1167
1290
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
1168
1291
  */