@disy/cadenza.js 10.5.5 → 10.5.7

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 (68) hide show
  1. package/CHANGELOG.md +11 -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 +39 -35
  6. package/apidoc/classes/CadenzaError.html +5 -5
  7. package/apidoc/functions/cadenza.html +4 -4
  8. package/apidoc/index.html +25 -25
  9. package/apidoc/interfaces/AreaIntersectionsResult.html +4 -4
  10. package/apidoc/interfaces/CadenzaClientOptions.html +6 -6
  11. package/apidoc/interfaces/CadenzaEvent.html +4 -4
  12. package/apidoc/interfaces/CommonEditGeometryOptions.html +13 -11
  13. package/apidoc/interfaces/Distance.html +2 -2
  14. package/apidoc/interfaces/ExternalLinkKey.html +4 -4
  15. package/apidoc/interfaces/Feature.html +9 -9
  16. package/apidoc/interfaces/FeatureCollection.html +4 -4
  17. package/apidoc/interfaces/Geometry.html +4 -4
  18. package/apidoc/interfaces/GeometryExtentStrategy.html +4 -4
  19. package/apidoc/interfaces/LayerDataExtentStrategy.html +4 -4
  20. package/apidoc/interfaces/LayerDefinition.html +4 -4
  21. package/apidoc/interfaces/LocationFinderExtentStrategy.html +4 -4
  22. package/apidoc/interfaces/PageSource.html +3 -3
  23. package/apidoc/interfaces/ProblemDetails.html +6 -6
  24. package/apidoc/interfaces/SnappingOptions.html +3 -3
  25. package/apidoc/interfaces/SpatialFilterValue.html +4 -4
  26. package/apidoc/interfaces/StaticExtentStrategy.html +4 -4
  27. package/apidoc/modules.html +1 -1
  28. package/apidoc/types/AttributeValue.html +3 -0
  29. package/apidoc/types/CadenzaActionEvent.html +2 -2
  30. package/apidoc/types/CadenzaChangeExtentEvent.html +2 -2
  31. package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
  32. package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
  33. package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
  34. package/apidoc/types/CadenzaEditGeometryCreateEvent.html +2 -2
  35. package/apidoc/types/CadenzaEditGeometryDeleteEvent.html +2 -2
  36. package/apidoc/types/CadenzaEditGeometryEditEvent.html +2 -2
  37. package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
  38. package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
  39. package/apidoc/types/CadenzaErrorEvent.html +2 -2
  40. package/apidoc/types/CadenzaEventByType.html +1 -1
  41. package/apidoc/types/CadenzaEventType.html +2 -2
  42. package/apidoc/types/CadenzaReloadEvent.html +2 -2
  43. package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
  44. package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
  45. package/apidoc/types/Coordinate.html +2 -2
  46. package/apidoc/types/CustomValidityType.html +2 -2
  47. package/apidoc/types/DataType.html +2 -2
  48. package/apidoc/types/EmbeddingTargetId.html +2 -2
  49. package/apidoc/types/Extent.html +2 -2
  50. package/apidoc/types/ExtentStrategy.html +2 -2
  51. package/apidoc/types/FilterVariables.html +7 -6
  52. package/apidoc/types/GeometryType.html +2 -2
  53. package/apidoc/types/GlobalId.html +2 -2
  54. package/apidoc/types/Layout.html +2 -2
  55. package/apidoc/types/LengthUnit.html +1 -1
  56. package/apidoc/types/LenientAttributeValue.html +21 -0
  57. package/apidoc/types/OpaqueString.html +2 -2
  58. package/apidoc/types/OperationMode.html +2 -2
  59. package/apidoc/types/Polygon.html +1 -1
  60. package/apidoc/types/SpatialRelation.html +2 -2
  61. package/apidoc/types/TablePart.html +2 -2
  62. package/apidoc/types/UiFeature.html +2 -2
  63. package/apidoc/types/WorkbookLayerPath.html +2 -2
  64. package/apidoc/types/WorksheetPlaceholders.html +2 -2
  65. package/cadenza.d.ts +54 -30
  66. package/cadenza.js +101 -41
  67. package/package.json +3 -5
  68. package/sandbox.html +16 -4
package/cadenza.js CHANGED
@@ -18,7 +18,7 @@
18
18
  */
19
19
  // This placeholder is replaced when Cadenza JS is released,
20
20
  // i.e. during development, the version is not available.
21
- const CADENZAJS_VERSION = '10.5.5';
21
+ const CADENZAJS_VERSION = '10.5.7';
22
22
  /**
23
23
  * Creates an instance of the Cadenza JS client.
24
24
  *
@@ -177,6 +177,7 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
177
177
  * @property {OperationMode} [operationMode] - The mode in which a workbook should be operated
178
178
  * @property {AbortSignal} [signal] - A signal to abort the iframe loading
179
179
  * @property {SnappingOptions} [snapping] - Passing these options enables snapping
180
+ * @property {boolean} [hideLegend] - Whether the legend should be hidden initially. Default is true.
180
181
  * @property {boolean} [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)
181
182
  */
182
183
  /**
@@ -186,13 +187,26 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
186
187
  */
187
188
  /** @typedef {'columns' | 'values' | 'totals'} TablePart - A part of a table to export */
188
189
  /**
189
- * @typedef {Record<string, string | string[] | number | Date | SpatialFilterValue | null>} FilterVariables - Filter variable names and values
190
+ * @typedef {string | number} AttributeValue - The value of a Cadenza attribute
190
191
  *
191
- * Variables of type String, Integer, Long, Double and Date can be set.
192
- * A property named "$spatial" reflects a Spatial filter value and must adhere to type {@link SpatialFilterValue}.
192
+ * The exact representation is described in [JSON Representation of Cadenza Object Data](../index.html#json-representation-of-cadenza-object-data).
193
+ */
194
+ /**
195
+ * @typedef {AttributeValue | bigint | Date} LenientAttributeValue - A lenient variant of {@link AttributeValue} that - for convenience - allows more values.
196
+ *
197
+ * Here's how the values are converted to proper attribute values:
198
+ *
199
+ * | `LenientAttributeValue` | Conversion to `AttributeType` |
200
+ * |-------------------------|-------------------------------|
201
+ * | `bigint` | `value.toString()` |
202
+ * | `Date` | `value.toISOString()` |
203
+ */
204
+ /**
205
+ * @typedef {Record<string, LenientAttributeValue | string[] | SpatialFilterValue | null>} FilterVariables - Filter variable names and values
193
206
  *
194
- * _Note:_ Since numbers in JavaScript are Double values ([more info on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_encoding)),
195
- * for Long variables, the API is currently limited to the Double value range.
207
+ * - Use `null` to unset a filter variable.
208
+ * - Use a `string` array to pass multiple values for a variable that is used in an `IN` expression.
209
+ * - The name "$spatial" reflects a Spatial filter value and must adhere to type {@link SpatialFilterValue}.
196
210
  */
197
211
  /**
198
212
  * @typedef SpatialFilterValue - Defines a spatial filter variable value.
@@ -207,7 +221,7 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
207
221
  /**
208
222
  * @typedef Feature - A adapted [GeoJSON](https://geojson.org/) feature object.
209
223
  * @property {'Feature'} type - The object's type
210
- * @property {any[]} objectId - The id of the feature
224
+ * @property {AttributeValue[]} objectId - The id of the feature
211
225
  * @property {Geometry} geometry - The geometry
212
226
  * @property {Record<string, string>} properties - The formated properties
213
227
  * @property {number} [area] - The area of a `Polygon` feature
@@ -505,8 +519,9 @@ export class CadenzaClient {
505
519
  */
506
520
  setFilter(filter) {
507
521
  this.#log('CadenzaClient#setFilter', ...arguments);
508
- assertValidFilterVariables(filter);
509
- return this.#postRequest('setFilter', { filter });
522
+ return this.#postRequest('setFilter', {
523
+ filter: sanitizeAndValidateFilterVariables(filter),
524
+ });
510
525
  }
511
526
  /**
512
527
  * Set the visibility of a layer in the currently shown workbook map view.
@@ -531,7 +546,7 @@ export class CadenzaClient {
531
546
  * Set the selection in the currently shown workbook map view.
532
547
  *
533
548
  * @param {WorkbookLayerPath | string} layer - The data view layer to set the selection in
534
- * @param {unknown[][]} values - The IDs of the objects to select
549
+ * @param {LenientAttributeValue[][]} values - The IDs of the objects to select
535
550
  * @param {object} [__namedParameters]
536
551
  * @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
537
552
  * @return {Promise<void>} A `Promise` for when the selection was set.
@@ -541,7 +556,7 @@ export class CadenzaClient {
541
556
  this.#log('CadenzaClient#setSelection', ...arguments);
542
557
  const selectionResult = this.#postRequest('setSelection', {
543
558
  layer: array(layer),
544
- values,
559
+ values: values.map(sanitizeAndValidateAttributeValues),
545
560
  });
546
561
  this.#setExtentStrategy(extentStrategy);
547
562
  return selectionResult;
@@ -550,7 +565,7 @@ export class CadenzaClient {
550
565
  * Add to the selection in the currently shown workbook map view.
551
566
  *
552
567
  * @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
553
- * @param {unknown[][]} values - The IDs of the objects to select
568
+ * @param {LenientAttributeValue[][]} values - The IDs of the objects to select
554
569
  * @param {object} [__namedParameters]
555
570
  * @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
556
571
  * @return {Promise<void>} A `Promise` for when the selection was changed.
@@ -560,7 +575,7 @@ export class CadenzaClient {
560
575
  this.#log('CadenzaClient#addSelection', ...arguments);
561
576
  const selectionResult = this.#postRequest('addSelection', {
562
577
  layer: array(layer),
563
- values,
578
+ values: values.map(sanitizeAndValidateAttributeValues),
564
579
  });
565
580
  this.#setExtentStrategy(extentStrategy);
566
581
  return selectionResult;
@@ -569,7 +584,7 @@ export class CadenzaClient {
569
584
  * Remove from the selection in the currently shown workbook map view.
570
585
  *
571
586
  * @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
572
- * @param {unknown[][]} values - The IDs of the objects to unselect
587
+ * @param {LenientAttributeValue[][]} values - The IDs of the objects to unselect
573
588
  * @param {object} [__namedParameters]
574
589
  * @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
575
590
  * @return {Promise<void>} A `Promise` for when the selection was changed.
@@ -579,7 +594,7 @@ export class CadenzaClient {
579
594
  this.#log('CadenzaClient#removeSelection', ...arguments);
580
595
  const selectionResult = this.#postRequest('removeSelection', {
581
596
  layer: array(layer),
582
- values,
597
+ values: values.map(sanitizeAndValidateAttributeValues),
583
598
  });
584
599
  this.#setExtentStrategy(extentStrategy);
585
600
  return selectionResult;
@@ -602,7 +617,7 @@ export class CadenzaClient {
602
617
  * - {@link CadenzaEditGeometryCancelEvent}
603
618
  * @embed
604
619
  */
605
- async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
620
+ async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, useMapSrs, operationMode, signal, snapping, hideLegend = true, } = {}) {
606
621
  this.#log('CadenzaClient#createGeometry', ...arguments);
607
622
  const validExtentStrategy = sanitizeExtentStrategy({
608
623
  extentStrategy,
@@ -612,6 +627,7 @@ export class CadenzaClient {
612
627
  disabledUiFeatures,
613
628
  filter,
614
629
  geometryType,
630
+ hideLegend,
615
631
  minScale,
616
632
  operationMode,
617
633
  snapping,
@@ -641,7 +657,7 @@ export class CadenzaClient {
641
657
  * - {@link CadenzaEditGeometryCancelEvent}
642
658
  * @embed
643
659
  */
644
- async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
660
+ async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, hideLegend = true, } = {}) {
645
661
  this.#log('CadenzaClient#editGeometry', ...arguments);
646
662
  const geometryType = geometry.type;
647
663
  assertValidGeometryType(geometryType);
@@ -654,6 +670,7 @@ export class CadenzaClient {
654
670
  disabledUiFeatures,
655
671
  filter,
656
672
  geometryType,
673
+ hideLegend,
657
674
  minScale,
658
675
  operationMode,
659
676
  snapping,
@@ -687,7 +704,7 @@ export class CadenzaClient {
687
704
  * - {@link CadenzaEditGeometryCancelEvent}
688
705
  * @embed
689
706
  */
690
- async batchCreateGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
707
+ async batchCreateGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, hideLegend = true, } = {}) {
691
708
  this.#log('CadenzaClient#editGeometry', ...arguments);
692
709
  assertValidGeometryType(geometryType);
693
710
  const validExtentStrategy = sanitizeExtentStrategy({
@@ -699,6 +716,7 @@ export class CadenzaClient {
699
716
  disabledUiFeatures,
700
717
  filter,
701
718
  geometryType,
719
+ hideLegend,
702
720
  minScale,
703
721
  operationMode,
704
722
  snapping,
@@ -731,7 +749,7 @@ export class CadenzaClient {
731
749
  * - {@link CadenzaEditGeometryCancelEvent}
732
750
  * @embed
733
751
  */
734
- async batchEditGeometry(backgroundMapView, features, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
752
+ async batchEditGeometry(backgroundMapView, features, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, hideLegend = true, } = {}) {
735
753
  this.#log('CadenzaClient#editGeometry', ...arguments);
736
754
  const geometryType = getGeometryTypeFromFeatureCollection(features);
737
755
  const validExtentStrategy = sanitizeExtentStrategy({
@@ -744,6 +762,7 @@ export class CadenzaClient {
744
762
  disabledUiFeatures,
745
763
  filter,
746
764
  geometryType,
765
+ hideLegend,
747
766
  minScale,
748
767
  operationMode,
749
768
  snapping,
@@ -813,15 +832,23 @@ export class CadenzaClient {
813
832
  #setEditFeature(objectId) {
814
833
  return this.#postRequest('requestEditFeature', objectId);
815
834
  }
835
+ /**
836
+ * Sets editor state to ready.
837
+ */
816
838
  #setEditorStateToReady() {
817
839
  return this.#postRequest('setEditorState', 'READY');
818
840
  }
819
841
  /**
820
- * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
821
- * warnings). When set to error the dialog submission is blocked.
822
- * If there already is a custom state set it will override it.
823
- * Passing '' will reset the custom state to undefined, meaning no custom state is displayed.
824
- * If no geometry editing is started, the method call has no effect.
842
+ * Set the custom validation status of the geometry editor dialog ( {@link createGeometry}, {@link editGeometry}, {@link batchCreateGeometry}, {@link batchEditGeometry} )
843
+ * or the {@link selectObjects} dialog in addition to the default validation status (including errors and warnings).
844
+ *
845
+ * Behavior:
846
+ * - When the custom validation status is of type 'error', the dialog submission is blocked.
847
+ * - If a custom validation status is already set, it will be overwritten.
848
+ * - Passing '' (an empty string) as the message parameter resets the custom validation status, which means no custom validation status is displayed.
849
+ *
850
+ * If neither the geometry editor nor {@link selectObjects} is started, the method call has no effect.
851
+ *
825
852
  * @param {string} message The message to show in the dialog
826
853
  * @param {CustomValidityType} [type] The type of message (defaults to 'error')
827
854
  */
@@ -1094,7 +1121,7 @@ export class CadenzaClient {
1094
1121
  * @param {EmbeddingTargetId} source - The workbook view to fetch object info from.
1095
1122
  * @param {(WorkbookLayerPath | string)[]} layerPath - Layer path to identify the layer
1096
1123
  * (identified using layer paths or print names)
1097
- * @param {unknown[][]} objectIds - The IDs of the objects to select
1124
+ * @param {LenientAttributeValue[][]} objectIds - The IDs of the objects to select
1098
1125
  * @param {object} [__namedParameters] - Options
1099
1126
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
1100
1127
  * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
@@ -1110,7 +1137,7 @@ export class CadenzaClient {
1110
1137
  });
1111
1138
  return this.#fetch(resolvePath(source) + '/objectinfo', params, signal, JSON.stringify({
1112
1139
  fullGeometries,
1113
- objectIds,
1140
+ objectIds: objectIds.map(sanitizeAndValidateAttributeValues),
1114
1141
  layerPath: array(layerPath),
1115
1142
  useMapSrs,
1116
1143
  })).then((response) => response.json());
@@ -1233,6 +1260,7 @@ export class CadenzaClient {
1233
1260
  * @param {string} [params.fileName]
1234
1261
  * @param {FilterVariables} [params.filter]
1235
1262
  * @param {GeometryType} [params.geometryType]
1263
+ * @param {boolean} [params.hideLegend]
1236
1264
  * @param {boolean} [params.hideMainHeaderAndFooter]
1237
1265
  * @param {boolean} [params.hideWorkbookToolBar]
1238
1266
  * @param {GlobalId} [params.highlightGlobalId]
@@ -1249,12 +1277,12 @@ export class CadenzaClient {
1249
1277
  * @param {Layout} [params.layout]
1250
1278
  * @return {URLSearchParams}
1251
1279
  */
1252
- #createParams({ action, batchModeEnabled, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, worksheetPlaceholders, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
1280
+ #createParams({ action, batchModeEnabled, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideLegend, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, worksheetPlaceholders, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
1253
1281
  if (disabledUiFeatures) {
1254
1282
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
1255
1283
  }
1256
1284
  if (filter) {
1257
- assertValidFilterVariables(filter);
1285
+ filter = sanitizeAndValidateFilterVariables(filter);
1258
1286
  }
1259
1287
  if (geometryType) {
1260
1288
  assertValidGeometryType(geometryType);
@@ -1293,7 +1321,7 @@ export class CadenzaClient {
1293
1321
  ...(filter &&
1294
1322
  Object.fromEntries(Object.entries(filter).map(([variable, value]) => [
1295
1323
  `filter.${variable}`,
1296
- JSON.stringify(value instanceof Date ? value.toISOString() : value),
1324
+ value,
1297
1325
  ]))),
1298
1326
  ...(worksheetPlaceholders &&
1299
1327
  Object.fromEntries(Object.entries(worksheetPlaceholders).map(([placeholderId, worksheetPrintName]) => [
@@ -1301,6 +1329,7 @@ export class CadenzaClient {
1301
1329
  JSON.stringify(worksheetPrintName),
1302
1330
  ]))),
1303
1331
  ...(geometryType && { geometryType }),
1332
+ ...(hideLegend && { hideLegend: 'true' }),
1304
1333
  ...(hideMainHeaderAndFooter && { hideMainHeaderAndFooter: 'true' }),
1305
1334
  ...(hideWorkbookToolBar && { hideWorkbookToolBar: 'true' }),
1306
1335
  ...(highlightGlobalId && { highlightGlobalId }),
@@ -1427,10 +1456,7 @@ function assertSupportedDataType(
1427
1456
  assert(supportedTypes.includes(type), `Invalid data type: ${type}`);
1428
1457
  }
1429
1458
  function validSpatialFilterValue(/** @type SpatialFilterValue */ $spatial) {
1430
- if ($spatial === null) {
1431
- return true;
1432
- }
1433
- if (typeof $spatial === 'object') {
1459
+ if (typeof $spatial === 'object' && $spatial != null) {
1434
1460
  return (validSpatialRelation($spatial.spatialRelation) &&
1435
1461
  validSpatialFilterGeometry($spatial.geometry));
1436
1462
  }
@@ -1442,11 +1468,45 @@ function validSpatialRelation(/** @type SpatialRelation */ spatialRelation) {
1442
1468
  function validSpatialFilterGeometry(/** @type Polygon */ geometry) {
1443
1469
  return typeof geometry === 'object' && geometry.type === 'Polygon';
1444
1470
  }
1445
- function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
1446
- const { $spatial, ...otherFilter } = filter;
1447
- assert($spatial === undefined ||
1448
- validSpatialFilterValue(/** @type {SpatialFilterValue} */ ($spatial)), 'Invalid value for spatial filter value under $spatial property');
1449
- Object.keys(otherFilter).forEach((varName) => assert(validKebabCaseString(varName), `Invalid filter variable name: ${varName}`));
1471
+ /** @return {AttributeValue} */
1472
+ function sanitizeAttributeValue(/** @type {LenientAttributeValue} */ value) {
1473
+ if (typeof value === 'bigint') {
1474
+ value = value.toString();
1475
+ }
1476
+ if (value instanceof Date) {
1477
+ value = value.toISOString();
1478
+ }
1479
+ return value;
1480
+ }
1481
+ function validAttributeValue(/** @type unknown */ value) {
1482
+ return typeof value === 'string' || typeof value === 'number';
1483
+ }
1484
+ function sanitizeAndValidateAttributeValues(
1485
+ /** @type {LenientAttributeValue[]} */ values) {
1486
+ return values.map((value) => {
1487
+ value = sanitizeAttributeValue(value);
1488
+ assert(validAttributeValue(value), `Invalid attribute value`);
1489
+ return value;
1490
+ });
1491
+ }
1492
+ function sanitizeAndValidateFilterVariables(
1493
+ /** @type {FilterVariables} */ filter) {
1494
+ return Object.fromEntries(Object.entries(filter).map(([varName, value = null]) => {
1495
+ if (varName === '$spatial') {
1496
+ assert(value == null ||
1497
+ validSpatialFilterValue(/** @type {SpatialFilterValue} */ (value)), 'Invalid value for spatial filter ($spatial)');
1498
+ }
1499
+ else {
1500
+ assert(validKebabCaseString(varName), `Invalid filter variable name: ${varName}`);
1501
+ if (value != null &&
1502
+ !(Array.isArray(value) && value.every((v) => typeof v === 'string'))) {
1503
+ value = sanitizeAttributeValue(
1504
+ /** @type {LenientAttributeValue} */ (value));
1505
+ assert(validAttributeValue(value), `Invalid value for filter variable "${varName}"`);
1506
+ }
1507
+ }
1508
+ return [varName, value];
1509
+ }));
1450
1510
  }
1451
1511
  function assertValidWorksheetPlaceholdersValues(
1452
1512
  /** @type {WorksheetPlaceholders} */ worksheetPlaceholders) {
@@ -1562,12 +1622,12 @@ function getGeometryTypeFromFeatureCollection(featureCollection) {
1562
1622
  * The extent is transformed according to the `useMapSrs` option.
1563
1623
  */
1564
1624
  /**
1565
- * @typedef {CadenzaEvent<'change:selection', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaChangeSelectionEvent - When the user changed the selection. `undefined` if no objects were selected.
1625
+ * @typedef {CadenzaEvent<'change:selection', undefined | {layer: WorkbookLayerPath, values: AttributeValue[][]}>} CadenzaChangeSelectionEvent - When the user changed the selection. `undefined` if no objects were selected.
1566
1626
  *
1567
1627
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
1568
1628
  */
1569
1629
  /**
1570
- * @typedef {CadenzaEvent<'drillThrough', {context?: string, values: unknown[][]}>} CadenzaDrillThroughEvent - When the user executed a POST message drill-through.
1630
+ * @typedef {CadenzaEvent<'drillThrough', {context?: string, values: AttributeValue[][]}>} CadenzaDrillThroughEvent - When the user executed a POST message drill-through.
1571
1631
  * <p>
1572
1632
  * The event includes a data row for every item in the workbook selection, each row consisting of the values of
1573
1633
  * the attributes that were selected for the POST message content. If the drill-through was executed from a map
@@ -1583,7 +1643,7 @@ function getGeometryTypeFromFeatureCollection(featureCollection) {
1583
1643
  /** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
1584
1644
  /** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
1585
1645
  /**
1586
- * @typedef {CadenzaEvent<'selectObjects:ok', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection. `undefined` if no objects were selected.
1646
+ * @typedef {CadenzaEvent<'selectObjects:ok', undefined | {layer: WorkbookLayerPath, values: AttributeValue[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection. `undefined` if no objects were selected.
1587
1647
  *
1588
1648
  * For a selection in a workbook map view with activated feature info, the values also include the simplified geometries of the selected objects.
1589
1649
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "10.5.5",
3
+ "version": "10.5.7",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",
@@ -18,21 +18,19 @@
18
18
  "build": "run-p validate:* build:*",
19
19
  "build:docs": "typedoc",
20
20
  "build:ts": "tsc",
21
- "validate:format": "prettier ./src --check",
21
+ "validate:format": "prettier ./src/**/*.{js,ts} --check",
22
22
  "validate:changelog": "changelog --latest-release",
23
23
  "start": "run-p start:*",
24
24
  "start:docs": "npm run build:docs -- --watch",
25
25
  "start:test": "npm test -- --watch",
26
26
  "start:ts": "npm run build:ts -- --watch",
27
- "start:reformat": "onchange \"src/**/*\" -- prettier {{changed}} --write",
27
+ "start:reformat": "onchange \"src/**/*.js\" \"src/**/*.ts\" -- prettier {{changed}} --write",
28
28
  "test": "cross-env NODE_OPTIONS=--unhandled-rejections=warn jest",
29
- "deploy:docs": "gh-pages --dist apidoc",
30
29
  "sandbox": "node ./sandbox.cjs"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@types/jest": "29.5.14",
34
33
  "cross-env": "7.0.3",
35
- "gh-pages": "6.3.0",
36
34
  "http-server": "14.1.1",
37
35
  "jest": "29.7.0",
38
36
  "jest-environment-jsdom": "29.7.0",
package/sandbox.html CHANGED
@@ -243,6 +243,7 @@
243
243
  minScale,
244
244
  parts,
245
245
  requestAsPdf,
246
+ showLegend,
246
247
  simplifiedOperationMode,
247
248
  snappingLayer,
248
249
  useAutoCorrection,
@@ -272,6 +273,7 @@
272
273
  layers: layers ? JSON.parse(layers) : undefined,
273
274
  minScale: minScale && Number(minScale),
274
275
  operationMode: (simplifiedOperationMode === 'on' ? 'simplified' : 'normal' ),
276
+ hideLegend: showLegend !== 'on',
275
277
  parts: parts && parts.split(','),
276
278
  snapping: snappingLayer ? {
277
279
  layer: JSON.parse(snappingLayer),
@@ -446,6 +448,7 @@
446
448
  <small>
447
449
  <p>A JSON object with filter variable names and values</p>
448
450
  <p>Dates need to be ISO strings<br>(e.g. <code>"2023-11-17T17:12:06.175Z"</code>).<br>Use <code>"{{currentDate}}"</code> for the current date.</p>
451
+ <p>Longs need to be strings (e.g. <code>"1234567890"</code>).</p>
449
452
  <p>Pass multiple values for an <code>IN</code> expression as <code>["a", "b", ...]</code></p>
450
453
  <p>Spatial filter values can be set using the dedicated <code>"$spatial"</code> variable name:
451
454
  <ul>
@@ -576,14 +579,14 @@
576
579
 
577
580
  <template data-action="setFilter" data-common="filter"></template>
578
581
 
579
- <template data-action="createGeometry" data-common="geometryType,simplifiedOperationMode,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
582
+ <template data-action="createGeometry" data-common="geometryType,simplifiedOperationMode,showLegend,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
580
583
  <div>
581
584
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
582
585
  <input name="embeddingTargetId" id="embeddingTargetId" required>
583
586
  </div>
584
587
  </template>
585
588
 
586
- <template data-action="editGeometry" data-common="simplifiedOperationMode,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
589
+ <template data-action="editGeometry" data-common="simplifiedOperationMode,showLegend,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
587
590
  <div>
588
591
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
589
592
  <input name="embeddingTargetId" id="embeddingTargetId" required>
@@ -610,14 +613,14 @@
610
613
  </div>
611
614
  </template>
612
615
 
613
- <template data-action="batchCreateGeometry" data-common="geometryType,simplifiedOperationMode,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
616
+ <template data-action="batchCreateGeometry" data-common="geometryType,simplifiedOperationMode,showLegend,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
614
617
  <div>
615
618
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
616
619
  <input name="embeddingTargetId" id="embeddingTargetId" required>
617
620
  </div>
618
621
  </template>
619
622
 
620
- <template data-action="batchEditGeometry" data-common="simplifiedOperationMode,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
623
+ <template data-action="batchEditGeometry" data-common="simplifiedOperationMode,showLegend,minimumScale,additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
621
624
  <div>
622
625
  <label for="embeddingTargetId">Embedding target ID of the map view *</label>
623
626
  <input name="embeddingTargetId" id="embeddingTargetId" required>
@@ -751,6 +754,15 @@
751
754
  </div>
752
755
  </template>
753
756
 
757
+ <template id="common-showLegend">
758
+ <div>
759
+ <label>
760
+ <input type="checkbox" name="showLegend">
761
+ Show Legend
762
+ </label>
763
+ </div>
764
+ </template>
765
+
754
766
  <template id="common-minimumScale">
755
767
  <div>
756
768
  <label for="minScale">Minimum Scale</label>