@disy/cadenza.js 10.2.3 → 10.2.5

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 (56) hide show
  1. package/CHANGELOG.md +17 -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 +119 -36
  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 +9 -9
  14. package/apidoc/interfaces/FeatureCollection.html +4 -4
  15. package/apidoc/interfaces/Geometry.html +4 -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 +8 -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/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 +161 -125
  52. package/cadenza.js +229 -114
  53. package/package.json +1 -1
  54. package/sandbox.html +126 -40
  55. package/apidoc/interfaces/GeometryZoomTarget.html +0 -4
  56. package/apidoc/types/ZoomTarget.html +0 -2
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
@@ -118,11 +124,34 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
118
124
  */
119
125
  /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */
120
126
  /**
121
- * @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.
122
150
  */
123
151
  /**
124
- * @typedef GeometryZoomTarget - Instructs Cadenza to zoom to a provided {@Link Geometry}
125
- * @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.
126
155
  */
127
156
  /**
128
157
  * @typedef {'csv' | 'excel' | 'json' | 'pdf' | 'png'} DataType - A data type
@@ -168,7 +197,8 @@ let firstEmbeddingTargetShown;
168
197
  * When aborted, the result Promise is rejected with an {@link AbortError}.
169
198
  * * If there's another error, the result Promise is rejected with a {@link CadenzaError}.
170
199
  * * For methods that support the `hideMainHeaderAndFooter` and `hideWorkbookToolBar` parameters - the parameters cannot override the configuration of an embedding target.
171
- * * 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.
172
202
  */
173
203
  // Must be exported to be included in the docs.
174
204
  export class CadenzaClient {
@@ -189,7 +219,7 @@ export class CadenzaClient {
189
219
  /**
190
220
  *
191
221
  * @hidden
192
- * @param {CadenzaClientOptions} [options]
222
+ * @param {CadenzaClientOptions} [__namedParameters]
193
223
  */
194
224
  constructor({ baseUrl, debug = false, iframe, webApplication } = {}) {
195
225
  if (webApplication) {
@@ -246,19 +276,19 @@ export class CadenzaClient {
246
276
  * Show a page, workbook, worksheet or workbook view in an iframe.
247
277
  *
248
278
  * @param {PageSource | EmbeddingTargetId} source - The source to show
249
- * @param {object} [options]
250
- * @param {DataType} [options.dataType] - Set to 'pdf' for embedding targets of type report and of views with view
279
+ * @param {object} [__namedParameters]
280
+ * @param {DataType} [__namedParameters.dataType] - Set to 'pdf' for embedding targets of type report and of views with view
251
281
  * type of "JasperReports report" to show the generated report PDF directly (without any Cadenza headers or
252
282
  * footers).
253
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
254
- * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
255
- * @param {FilterVariables} [options.filter] - Filter variables
256
- * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
257
- * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
258
- * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
259
- * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
260
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
261
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
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
262
292
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
263
293
  * @throws For invalid arguments
264
294
  * @fires
@@ -291,8 +321,8 @@ export class CadenzaClient {
291
321
  }
292
322
  /**
293
323
  * Reload the views of a worksheet.
294
- * @param {object} [options] - Options
295
- * @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
296
326
  * in the worksheet
297
327
  * @postMessage
298
328
  */
@@ -313,20 +343,21 @@ export class CadenzaClient {
313
343
  * Show a workbook map view in an iframe.
314
344
  *
315
345
  * @param {EmbeddingTargetId} mapView - The workbook map view to show
316
- * @param {object} [options] - Options
317
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
318
- * @param {boolean} [options.expandNavigator] - Indicates if the navigator should be expanded.
319
- * @param {FilterVariables} [options.filter] - Filter variables
320
- * @param {Geometry} [options.geometry] - A geometry to show on the map
321
- * @param {boolean} [options.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
322
- * @param {boolean} [options.hideWorkbookToolBar] - Whether to hide the workbook toolbar
323
- * @param {GlobalId} [options.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
324
- * @param {string} [options.locationFinder] - A search query for the location finder
325
- * @param {Extent} [options.mapExtent] - A map extent to set
326
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
327
- * @param {boolean} [options.useMapSrs] - Whether the geometry and the extent are in the map's SRS (otherwise EPSG:4326 is assumed)
328
- * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
329
- * @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.
330
361
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
331
362
  * @throws For invalid arguments
332
363
  * @fires
@@ -334,12 +365,17 @@ export class CadenzaClient {
334
365
  * - {@link CadenzaActionEvent}
335
366
  * @embed
336
367
  */
337
- 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, } = {}) {
338
369
  this.#log('CadenzaClient#showMap', ...arguments);
339
370
  if (geometry) {
340
371
  assertValidGeometryType(geometry.type);
341
372
  }
342
- const zoomToGeometry = geometry && zoomTarget?.type === 'geometry';
373
+ const validExtentStrategy = sanitizeExtentStrategy({
374
+ geometry,
375
+ locationFinder,
376
+ mapExtent,
377
+ extentStrategy,
378
+ });
343
379
  const params = createParams({
344
380
  disabledUiFeatures,
345
381
  expandNavigator,
@@ -347,21 +383,23 @@ export class CadenzaClient {
347
383
  hideMainHeaderAndFooter,
348
384
  hideWorkbookToolBar,
349
385
  highlightGlobalId,
350
- // only use locationFinder if zoom to geometry is not set, to avoid
351
- // zooming race condition for Cadenza versions below 10.1
352
- locationFinder: zoomToGeometry ? undefined : locationFinder,
353
- mapExtent,
354
386
  operationMode,
355
387
  targetType: 'MAP',
356
388
  useMapSrs,
389
+ validExtentStrategy,
357
390
  });
358
391
  await this.#show(resolvePath(mapView), params, signal);
359
392
  if (geometry) {
360
393
  this.#postEvent('setGeometry', {
361
394
  geometry,
362
- zoomToGeometry,
363
395
  });
364
396
  }
397
+ if (additionalLayers) {
398
+ for (const layer of additionalLayers) {
399
+ await this.#postRequest('importLayer', layer);
400
+ }
401
+ }
402
+ this.#setExtentStrategy(validExtentStrategy);
365
403
  }
366
404
  /**
367
405
  * Expand/collapse the navigator.
@@ -463,12 +501,6 @@ export class CadenzaClient {
463
501
  values,
464
502
  });
465
503
  }
466
- /**
467
- * @typedef LayerDefinition
468
- * @property {string} name - The layer's name.
469
- * @property {'geojson'} type - The layer's type.
470
- * @property {FeatureCollection} content - The layer's content in geojson format.
471
- */
472
504
  /**
473
505
  * Create a geometry.
474
506
  *
@@ -477,16 +509,17 @@ export class CadenzaClient {
477
509
  *
478
510
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
479
511
  * @param {GeometryType} geometryType - The geometry type
480
- * @param {object} [options] - Options
481
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
482
- * @param {FilterVariables} [options.filter] - Filter variables
483
- * @param {string} [options.locationFinder] - A search query for the location finder
484
- * @param {Extent} [options.mapExtent] - A map extent to set
485
- * @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.
486
- * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used)
487
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
488
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
489
- * @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.
490
523
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
491
524
  * @throws For invalid arguments
492
525
  * @fires
@@ -495,40 +528,47 @@ export class CadenzaClient {
495
528
  * - {@link CadenzaEditGeometryCancelEvent}
496
529
  * @embed
497
530
  */
498
- 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, } = {}) {
499
532
  this.#log('CadenzaClient#createGeometry', ...arguments);
533
+ const validExtentStrategy = sanitizeExtentStrategy({
534
+ locationFinder,
535
+ mapExtent,
536
+ extentStrategy,
537
+ });
500
538
  const params = createParams({
501
539
  action: 'editGeometry',
502
540
  disabledUiFeatures,
503
541
  filter,
504
542
  geometryType,
505
- locationFinder,
506
- mapExtent,
507
543
  minScale,
508
- useMapSrs,
509
544
  operationMode,
545
+ useMapSrs,
546
+ validExtentStrategy,
510
547
  });
511
548
  await this.#show(resolvePath(backgroundMapView), params, signal);
512
549
  if (additionalLayers) {
513
- additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
550
+ for (const layer of additionalLayers) {
551
+ await this.#postRequest('importLayer', layer);
552
+ }
514
553
  }
554
+ this.#setExtentStrategy(validExtentStrategy);
515
555
  }
516
556
  /**
517
557
  * Edit a geometry.
518
558
  *
519
559
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
520
560
  * @param {Geometry} geometry - The geometry
521
- * @param {object} [options] - Options
522
- * @param {UiFeature[]} [options.disabledUiFeatures] - Cadenza UI features to disable
523
- * @param {FilterVariables} [options.filter] - Filter variables
524
- * @param {string} [options.locationFinder] - A search query for the location finder
525
- * @param {Extent} [options.mapExtent] - A map extent to set
526
- * @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.
527
- * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
528
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
529
- * @param {ZoomTarget} [options.zoomTarget] - A target Cadenza should zoom to
530
- * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
531
- * @param {LayerDefinition[]} [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.
532
572
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
533
573
  * @throws For invalid arguments
534
574
  * @fires
@@ -537,32 +577,36 @@ export class CadenzaClient {
537
577
  * - {@link CadenzaEditGeometryCancelEvent}
538
578
  * @embed
539
579
  */
540
- 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, } = {}) {
541
581
  this.#log('CadenzaClient#editGeometry', ...arguments);
542
582
  assertValidGeometryType(geometry.type);
543
- const zoomToGeometry = geometry && zoomTarget?.type === 'geometry';
583
+ const validExtentStrategy = sanitizeExtentStrategy({
584
+ geometry,
585
+ locationFinder,
586
+ mapExtent,
587
+ extentStrategy,
588
+ });
544
589
  const params = createParams({
545
590
  action: 'editGeometry',
546
591
  disabledUiFeatures,
547
592
  filter,
548
- // only use locationFinder if zoom to geometry is not set, to avoid
549
- // zooming race condition for Cadenza versions below 10.1
550
- locationFinder: zoomToGeometry ? undefined : locationFinder,
551
- mapExtent,
552
593
  minScale,
553
- useMapSrs,
554
594
  operationMode,
595
+ useMapSrs,
596
+ validExtentStrategy,
555
597
  });
556
598
  await this.#show(resolvePath(backgroundMapView), params, signal);
557
599
  if (geometry) {
558
600
  this.#postEvent('setGeometry', {
559
601
  geometry,
560
- zoomToGeometry,
561
602
  });
562
603
  }
563
604
  if (additionalLayers) {
564
- additionalLayers.forEach((layer) => this.#postEvent('importLayer', layer));
605
+ for (const layer of additionalLayers) {
606
+ await this.#postRequest('importLayer', layer);
607
+ }
565
608
  }
609
+ this.#setExtentStrategy(validExtentStrategy);
566
610
  }
567
611
  /**
568
612
  * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
@@ -581,15 +625,16 @@ export class CadenzaClient {
581
625
  * Select objects in a workbook map.
582
626
  *
583
627
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
584
- * @param {object} [options] - Options
585
- * @param {FilterVariables} [options.filter] - Filter variables
586
- * @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
587
631
  * (identified using layer paths or print names)
588
- * @param {string} [options.locationFinder] - A search query for the location finder
589
- * @param {Extent} [options.mapExtent] - A map extent to set
590
- * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
591
- * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
592
- * @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.
593
638
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
594
639
  * @throws For invalid arguments
595
640
  * @fires
@@ -599,18 +644,31 @@ export class CadenzaClient {
599
644
  * - {@link CadenzaSelectObjectsCancelEvent}
600
645
  * @embed
601
646
  */
602
- selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, } = {}) {
647
+ async selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
603
648
  this.#log('CadenzaClient#selectObjects', ...arguments);
649
+ const validExtentStrategy = sanitizeExtentStrategy({
650
+ geometry: undefined,
651
+ locationFinder,
652
+ mapExtent,
653
+ extentStrategy,
654
+ });
604
655
  const params = createParams({
605
656
  action: 'selectObjects',
606
657
  filter,
607
658
  layers: layers?.map(array),
608
- locationFinder,
609
- mapExtent,
610
659
  useMapSrs,
611
660
  operationMode,
661
+ validExtentStrategy,
612
662
  });
613
- 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
+ }
614
672
  }
615
673
  /**
616
674
  * @param {string} path
@@ -793,13 +851,13 @@ export class CadenzaClient {
793
851
  *
794
852
  * @param {EmbeddingTargetId} source - The workbook view to fetch data from.
795
853
  * @param {DataType} dataType - The data type you want to get back from the server.
796
- * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
854
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
797
855
  * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type
798
856
  * of "JasperReports report".
799
- * @param {object} [options] - Options
800
- * @param {FilterVariables} [options.filter] - Filter variables
801
- * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
802
- * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
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
803
861
  * @return {Promise<Response>} A `Promise` for the fetch response
804
862
  * @throws For invalid arguments
805
863
  * @server
@@ -817,11 +875,11 @@ export class CadenzaClient {
817
875
  * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer
818
876
  * (identified using layer paths or print names)
819
877
  * @param {unknown[][]} objectIds - The IDs of the objects to select
820
- * @param {object} [options] - Options
821
- * @param {FilterVariables} [options.filter] - Filter variables
822
- * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
823
- * @param {Boolean} [options.useMapSrs] - Use the map SRS instead of WGS84
824
- * @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
825
883
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
826
884
  * @throws For invalid arguments
827
885
  */
@@ -844,10 +902,10 @@ export class CadenzaClient {
844
902
  * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer
845
903
  * (identified using layer paths or print names)
846
904
  * @param {Geometry} geometry - The intersection geometry
847
- * @param {object} [options] - Options
848
- * @param {boolean} [options.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
849
- * @param {Distance} [options.buffer] - Buffer size for geometry of the transition
850
- * @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
851
909
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
852
910
  * @server
853
911
  */
@@ -897,13 +955,13 @@ export class CadenzaClient {
897
955
  *
898
956
  * @param {EmbeddingTargetId} source - The workbook view to fetch data from.
899
957
  * @param {DataType} dataType - The data type you want to get back from the server.
900
- * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
958
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported for embedding targets of type view with a view type of
901
959
  * table and indicator. `"pdf"` is supported for embedding targets of type report and of type view with a view type
902
960
  * of "JasperReports report".
903
- * @param {object} [options] - Options
904
- * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
905
- * @param {FilterVariables} [options.filter] - Filter variables
906
- * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
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.
907
965
  * @throws For invalid arguments
908
966
  * @server
909
967
  */
@@ -1047,16 +1105,15 @@ function assertSupportedDataType(
1047
1105
  * @param {GlobalId} [params.highlightGlobalId]
1048
1106
  * @param {string} [params.labelSet]
1049
1107
  * @param {WorkbookLayerPath[]} [params.layers]
1050
- * @param {string} [params.locationFinder]
1051
- * @param {Extent} [params.mapExtent]
1052
1108
  * @param {number} [params.minScale]
1053
1109
  * @param {OperationMode} [params.operationMode]
1054
1110
  * @param {TablePart[]} [params.parts]
1055
1111
  * @param {'MAP'} [params.targetType]
1056
1112
  * @param {boolean} [params.useMapSrs]
1113
+ * @param {ExtentStrategy | undefined} [params.validExtentStrategy]
1057
1114
  * @return {URLSearchParams}
1058
1115
  */
1059
- 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, }) {
1060
1117
  if (disabledUiFeatures) {
1061
1118
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
1062
1119
  }
@@ -1072,6 +1129,16 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1072
1129
  if (parts) {
1073
1130
  parts.forEach((part) => assert(validTablePart(part), `Invalid table part: ${part}`));
1074
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
+ }
1075
1142
  return new URLSearchParams({
1076
1143
  ...(action && { action }),
1077
1144
  ...(dataType && { dataType }),
@@ -1106,6 +1173,54 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1106
1173
  function array(/** @type unknown */ value) {
1107
1174
  return Array.isArray(value) ? value : [value];
1108
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
+ }
1109
1224
  // Please do not add internal event types like 'ready' here.
1110
1225
  /**
1111
1226
  * @typedef {'action'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "10.2.3",
3
+ "version": "10.2.5",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",