@disy/cadenza.js 2.2.2 β†’ 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/README.md +1 -322
  3. package/apidoc/assets/highlight.css +0 -7
  4. package/apidoc/assets/main.js +2 -2
  5. package/apidoc/assets/navigation.js +1 -1
  6. package/apidoc/assets/search.js +1 -1
  7. package/apidoc/assets/style.css +46 -15
  8. package/apidoc/classes/AbortError.html +3 -3
  9. package/apidoc/classes/CadenzaClient.html +68 -89
  10. package/apidoc/classes/CadenzaError.html +8 -6
  11. package/apidoc/functions/cadenza.html +6 -5
  12. package/apidoc/index.html +152 -9
  13. package/apidoc/interfaces/CadenzaEvent.html +6 -6
  14. package/apidoc/interfaces/ExternalLinkKey.html +6 -3
  15. package/apidoc/interfaces/Geometry.html +2 -2
  16. package/apidoc/interfaces/PageSource.html +2 -2
  17. package/apidoc/modules.html +14 -2
  18. package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -0
  19. package/apidoc/types/CadenzaDrillThroughEvent.html +7 -0
  20. package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -0
  21. package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -0
  22. package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -0
  23. package/apidoc/types/CadenzaErrorEvent.html +2 -2
  24. package/apidoc/types/CadenzaEventByType.html +1 -0
  25. package/apidoc/types/CadenzaEventType.html +2 -0
  26. package/apidoc/types/CadenzaObjectInfoEvent.html +2 -0
  27. package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -0
  28. package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -0
  29. package/apidoc/types/DataType.html +3 -2
  30. package/apidoc/types/EmbeddingTargetId.html +9 -2
  31. package/apidoc/types/Extent.html +1 -1
  32. package/apidoc/types/FilterVariables.html +5 -2
  33. package/apidoc/types/GeometryType.html +1 -1
  34. package/apidoc/types/GlobalId.html +2 -2
  35. package/apidoc/types/OpaqueString.html +6 -0
  36. package/apidoc/types/OperationMode.html +1 -1
  37. package/apidoc/types/TablePart.html +1 -1
  38. package/apidoc/types/UiFeature.html +3 -3
  39. package/apidoc/types/WorkbookLayerPath.html +3 -0
  40. package/cadenza.d.ts +321 -56
  41. package/cadenza.js +349 -71
  42. package/package.json +6 -6
  43. package/sandbox.html +197 -31
package/cadenza.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  * @param {ExternalLinkKey} [options.webApplication] - An external link that Cadenza uses to resolve the
10
10
  * [target origin](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#targetorigin) when posting events.
11
11
  * This is required if Cadenza and your application are not running on the same origin.
12
+ * Please ensure that the user has view privilege for that link!
12
13
  * @param {boolean} [options.debug] - Whether to enable debug logging
13
14
  * @throws For invalid arguments
14
15
  */
@@ -17,13 +18,42 @@ export function cadenza(baseUrl: string, options?: {
17
18
  webApplication?: ExternalLinkKey | undefined;
18
19
  debug?: boolean | undefined;
19
20
  } | undefined): CadenzaClient;
20
- /** @typedef {string} EmbeddingTargetId - The ID of an embedding target */
21
- /** @typedef {string} GlobalId - The ID of a navigator item */
21
+ /**
22
+ * @template {string} T
23
+ * @typedef {string & {__type: T}} OpaqueString - A specific `string` type that is not assignable from another string
24
+ *
25
+ * The idea is to have a specific type e.g. for the {@link EmbeddingTargetId} instead of a plain `string`.
26
+ * You don't need to _actually_ add that `__type` property. In TS code, just use a
27
+ * [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions)
28
+ * (e.g. `cadenzaClient.show('{embeddingTargetId}' as EmbeddingTargetId)`).
29
+ */
30
+ /**
31
+ * @typedef {OpaqueString<'EmbeddingTargetId'>} EmbeddingTargetId - The ID of a Cadenza embedding target
32
+ *
33
+ * Embedding targets are called πŸ‡©πŸ‡ͺ "Einbettbarer Inhalt" / πŸ‡ΊπŸ‡Έ "Embeddable content" throughout the Cadenza UI and help.
34
+ * They're managed within the respective workbook:
35
+ *
36
+ * - πŸ‡©πŸ‡ͺ "Mehr" > "Arbeitsmappe verwalten" > "Einbettung"
37
+ * - πŸ‡ΊπŸ‡Έ "More" > "Manage workbook" > "Embedding"
38
+ *
39
+ * The name of an embedding target (as entered in the UI) is its ID.
40
+ */
41
+ /** @typedef {OpaqueString<'GlobalId'>} GlobalId - The ID of a navigator item */
22
42
  /**
23
43
  * @typedef ExternalLinkKey - A tuple qualifying a Cadenza external link
44
+ *
45
+ * You get the `repositoryName` and `externalLinkId` from the URL of the external link's page in the Cadenza management center:
46
+ * ```
47
+ * {baseUrl}/admin/repositories/{repositoryName}/external-links/{externalLinkId}?...
48
+ * ```
49
+ *
24
50
  * @property {string} repositoryName - The name of the link's repository
25
51
  * @property {string} externalLinkId - The ID of the external link
26
52
  */
53
+ /**
54
+ * @typedef {string[]} WorkbookLayerPath - Identifies a layer within a workbook map view
55
+ * using the print names of the layer and - if the layer is grouped - its ancestors
56
+ */
27
57
  /**
28
58
  * @typedef PageSource - A well-known Cadenza page
29
59
  * @property {'welcome'} page - The name of the page (Only `"welcome"` is currently supported.)
@@ -33,8 +63,8 @@ export function cadenza(baseUrl: string, options?: {
33
63
  * @typedef {'workbook-design'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
34
64
  *
35
65
  * _Note:_ Supported features are:
36
- * * 'workbook-design' - The workbook designer
37
- * * 'workbook-view-management' - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
66
+ * * `"workbook-design"` - The workbook designer
67
+ * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
38
68
  * */
39
69
  /**
40
70
  * @typedef Geometry - A [GeoJSON](https://geojson.org/) geometry object
@@ -46,9 +76,20 @@ export function cadenza(baseUrl: string, options?: {
46
76
  * _Note:_ The GeoJSON geometry type "GeometryCollection" is currently not supported.
47
77
  */
48
78
  /** @typedef {[number,number,number,number]} Extent - An array of numbers representing an extent: [minx, miny, maxx, maxy] */
49
- /** @typedef {'csv' | 'excel' | 'json' | 'pdf'} DataType - A data type */
79
+ /**
80
+ * @typedef {'csv' | 'excel' | 'json' | 'pdf' | 'png'} DataType - A data type
81
+ *
82
+ * See [JSON Representation of Cadenza Object Data](../index.html#md:json-representation-of-cadenza-object-data) for JSON data.
83
+ */
50
84
  /** @typedef {'columns' | 'values' | 'totals'} TablePart - A part of a table to export */
51
- /** @typedef {Record<string, string | number | Date>} FilterVariables - Filter variable names and values */
85
+ /**
86
+ * @typedef {Record<string, string | string[] | number | Date | null>} FilterVariables - Filter variable names and values
87
+ *
88
+ * Variables of type String, Integer, Long, Double and Date can be set.
89
+ *
90
+ * _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)),
91
+ * for Long variables, the API is currently limited to the Double value range.
92
+ */
52
93
  /**
53
94
  * _Notes:_
54
95
  * * Most public methods can be aborted using an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
@@ -91,12 +132,9 @@ export class CadenzaClient {
91
132
  * @param {String} [options.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
92
133
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
93
134
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
94
- * @return {Promise<void>} A Promise for when the iframe is loaded
135
+ * @return {Promise<void>} A `Promise` for when the iframe is loaded
95
136
  * @throws For invalid arguments
96
- * @fires `drillThrough` - When the user executed a POST message drill-through.
97
- * The event includes a row of values for each row in the workbook selection, each row consisting of the values of
98
- * the attributes that were selected for the POST message content. If the drill-through was executed from a map
99
- * view, each row includes the geometry of the select object as the last value.
137
+ * @fires {@link CadenzaDrillThroughEvent}
100
138
  */
101
139
  show(source: PageSource | EmbeddingTargetId, { dataType, disabledUiFeatures, expandNavigator, filter, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, operationMode, signal, }?: {
102
140
  dataType?: DataType | undefined;
@@ -105,11 +143,11 @@ export class CadenzaClient {
105
143
  filter?: FilterVariables | undefined;
106
144
  hideMainHeaderAndFooter?: boolean | undefined;
107
145
  hideWorkbookToolBar?: boolean | undefined;
108
- highlightGlobalId?: string | undefined;
146
+ highlightGlobalId?: GlobalId | undefined;
109
147
  labelSet?: string | undefined;
110
148
  operationMode?: OperationMode | undefined;
111
149
  signal?: AbortSignal | undefined;
112
- } | undefined): Promise<void>;
150
+ } | undefined, ...args: any[]): Promise<void>;
113
151
  /**
114
152
  * Show a workbook map view in an iframe.
115
153
  *
@@ -127,11 +165,9 @@ export class CadenzaClient {
127
165
  * @param {OperationMode} [options.operationMode] - The mode in which a workbook should be operated
128
166
  * @param {boolean} [options.useMapSrs] - Whether the geometry and the extent are in the map's SRS (otherwise EPSG:4326 is assumed)
129
167
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
130
- * @return {Promise<void>} A Promise for when the iframe is loaded
168
+ * @return {Promise<void>} A `Promise` for when the iframe is loaded
131
169
  * @throws For invalid arguments
132
- * @fires `drillThrough` - When the user executed a POST message drill-through.
133
- * The event includes a row of values for each row in the workbook selection, each row consisting of the values of
134
- * the attributes that were selected for the POST message content plus the geometry of the select object as the last value.
170
+ * @fires {@link CadenzaDrillThroughEvent}
135
171
  */
136
172
  showMap(mapView: EmbeddingTargetId, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
137
173
  disabledUiFeatures?: UiFeature[] | undefined;
@@ -140,19 +176,78 @@ export class CadenzaClient {
140
176
  geometry?: Geometry | undefined;
141
177
  hideMainHeaderAndFooter?: boolean | undefined;
142
178
  hideWorkbookToolBar?: boolean | undefined;
143
- highlightGlobalId?: string | undefined;
179
+ highlightGlobalId?: GlobalId | undefined;
144
180
  locationFinder?: string | undefined;
145
181
  mapExtent?: Extent | undefined;
146
182
  operationMode?: OperationMode | undefined;
147
183
  useMapSrs?: boolean | undefined;
148
184
  signal?: AbortSignal | undefined;
149
- } | undefined): Promise<void>;
185
+ } | undefined, ...args: any[]): Promise<void>;
150
186
  /**
151
187
  * Expand/collapse the navigator.
152
188
  *
153
189
  * @param {boolean} expanded - The expansion state of the navigator
154
190
  */
155
- expandNavigator(expanded?: boolean): void;
191
+ expandNavigator(expanded?: boolean, ...args: any[]): void;
192
+ /**
193
+ * Get data from the currently shown workbook view.
194
+ *
195
+ * Currently, only map views are supported.
196
+ *
197
+ * @hidden
198
+ * @template {DataType} T
199
+ * @param {T} dataType - The requested data type. Currently, only `"png"` is supported.
200
+ * @return {Promise<T extends 'png' ? Blob : never>}
201
+ */
202
+ getData<T extends DataType>(dataType: T, ...args: any[]): Promise<T extends "png" ? Blob : never>;
203
+ /**
204
+ * Set filter variables in the currently shown workbook.
205
+ *
206
+ * @hidden
207
+ * @param {FilterVariables} filter - The variable values
208
+ * @return {Promise<void>} A `Promise` for when the filter variables were set.
209
+ */
210
+ setFilter(filter: FilterVariables, ...args: any[]): Promise<void>;
211
+ /**
212
+ * Set the visibility of a layer in the currently shown workbook map view.
213
+ *
214
+ * When making a layer visible, its ancestors will be made visible, too.
215
+ * When hiding a layer, the ancestors are not affected.
216
+ *
217
+ * @hidden
218
+ * @param {WorkbookLayerPath | string} layer - The layer to show or hide
219
+ * (identified using a layer path or a print name)
220
+ * @param {boolean} visible - The visibility state of the layer
221
+ * @return {Promise<void>} A `Promise` for when the layer visibility was set.
222
+ */
223
+ setLayerVisibility(layer: WorkbookLayerPath | string, visible: boolean, ...args: any[]): Promise<void>;
224
+ /**
225
+ * Set the selection in the currently shown workbook map view.
226
+ *
227
+ * @hidden
228
+ * @param {WorkbookLayerPath | string} layer - The data view layer to set the selection in
229
+ * @param {unknown[]} values - The IDs of the objects to select
230
+ * @return {Promise<void>} A `Promise` for when the selection was set.
231
+ */
232
+ setSelection(layer: WorkbookLayerPath | string, values: unknown[], ...args: any[]): Promise<void>;
233
+ /**
234
+ * Add to the selection in the currently shown workbook map view.
235
+ *
236
+ * @hidden
237
+ * @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
238
+ * @param {unknown[]} values - The IDs of the objects to select
239
+ * @return {Promise<void>} A `Promise` for when the selection was changed.
240
+ */
241
+ addSelection(layer: WorkbookLayerPath | string, values: unknown[], ...args: any[]): Promise<void>;
242
+ /**
243
+ * Remove from the selection in the currently shown workbook map view.
244
+ *
245
+ * @hidden
246
+ * @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
247
+ * @param {unknown[]} values - The IDs of the objects to unselect
248
+ * @return {Promise<void>} A `Promise` for when the selection was changed.
249
+ */
250
+ removeSelection(layer: WorkbookLayerPath | string, values: unknown[], ...args: any[]): Promise<void>;
156
251
  /**
157
252
  * Create a geometry.
158
253
  *
@@ -167,11 +262,12 @@ export class CadenzaClient {
167
262
  * @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.
168
263
  * @param {boolean} [options.useMapSrs] - Whether the created geometry should use the map's SRS (otherwise EPSG:4326 will be used)
169
264
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
170
- * @return {Promise<void>} A Promise for when the iframe is loaded
265
+ * @return {Promise<void>} A `Promise` for when the iframe is loaded
171
266
  * @throws For invalid arguments
172
- * @fires `editGeometry:update` - When the user changed the geometry. The event includes the edited geometry.
173
- * @fires `editGeometry:ok` - When the user completed the geometry editing. The event includes the edited geometry.
174
- * @fires `editGeometry:cancel` - When the user cancelled the geometry editing in Cadenza.
267
+ * @fires
268
+ * - {@link CadenzaEditGeometryUpdateEvent}
269
+ * - {@link CadenzaEditGeometryOkEvent}
270
+ * - {@link CadenzaEditGeometryCancelEvent}
175
271
  */
176
272
  createGeometry(backgroundMapView: EmbeddingTargetId, geometryType: GeometryType, { locationFinder, mapExtent, minScale, useMapSrs, signal }?: {
177
273
  locationFinder?: string | undefined;
@@ -179,7 +275,7 @@ export class CadenzaClient {
179
275
  minScale?: number | undefined;
180
276
  useMapSrs?: boolean | undefined;
181
277
  signal?: AbortSignal | undefined;
182
- } | undefined): Promise<void>;
278
+ } | undefined, ...args: any[]): Promise<void>;
183
279
  /**
184
280
  * Edit a geometry.
185
281
  *
@@ -191,11 +287,12 @@ export class CadenzaClient {
191
287
  * @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.
192
288
  * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
193
289
  * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
194
- * @return {Promise<void>} A Promise for when the iframe is loaded
290
+ * @return {Promise<void>} A `Promise` for when the iframe is loaded
195
291
  * @throws For invalid arguments
196
- * @fires `editGeometry:update` - When the user changed the geometry. The event includes the edited geometry.
197
- * @fires `editGeometry:ok` - When the user completed the geometry editing. The event includes the edited geometry.
198
- * @fires `editGeometry:cancel` - When the user cancelled the geometry editing in Cadenza.
292
+ * @fires
293
+ * - {@link CadenzaEditGeometryUpdateEvent}
294
+ * - {@link CadenzaEditGeometryOkEvent}
295
+ * - {@link CadenzaEditGeometryCancelEvent}
199
296
  */
200
297
  editGeometry(backgroundMapView: EmbeddingTargetId, geometry: Geometry, { locationFinder, mapExtent, minScale, useMapSrs, signal }?: {
201
298
  locationFinder?: string | undefined;
@@ -203,38 +300,68 @@ export class CadenzaClient {
203
300
  minScale?: number | undefined;
204
301
  useMapSrs?: boolean | undefined;
205
302
  signal?: AbortSignal | undefined;
206
- } | undefined): Promise<void>;
303
+ } | undefined, ...args: any[]): Promise<void>;
304
+ /**
305
+ * Select objects in a workbook map.
306
+ *
307
+ * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
308
+ * @param {object} [options] - Options
309
+ * @param {(WorkbookLayerPath | string)[]} [options.layers] - Layers to restrict the selection to
310
+ * (identified using layer paths or print names)
311
+ * @param {string} [options.locationFinder] - A search query for the location finder
312
+ * @param {Extent} [options.mapExtent] - A map extent to set
313
+ * @param {boolean} [options.useMapSrs] - Whether the geometry is in the map's SRS (otherwise EPSG:4326 is assumed)
314
+ * @param {AbortSignal} [options.signal] - A signal to abort the iframe loading
315
+ * @return {Promise<void>} A `Promise` for when the iframe is loaded
316
+ * @throws For invalid arguments
317
+ * @fires
318
+ * - {@link CadenzaChangeSelectionEvent}
319
+ * - {@link CadenzaObjectInfoEvent}
320
+ * - {@link CadenzaSelectObjectsOkEvent}
321
+ * - {@link CadenzaSelectObjectsCancelEvent}
322
+ */
323
+ selectObjects(backgroundMapView: EmbeddingTargetId, { layers, locationFinder, mapExtent, useMapSrs, signal }?: {
324
+ layers?: (string | WorkbookLayerPath)[] | undefined;
325
+ locationFinder?: string | undefined;
326
+ mapExtent?: Extent | undefined;
327
+ useMapSrs?: boolean | undefined;
328
+ signal?: AbortSignal | undefined;
329
+ } | undefined, ...args: any[]): Promise<void>;
207
330
  /**
208
331
  * Subscribe to a `postMessage()` event.
209
332
  *
210
- * @template [T=unknown]
211
- * @param {string} type - The event type
212
- * @param {(event: CadenzaEvent<T>) => void} subscriber - The subscriber function
333
+ * @template {CadenzaEventType} TYPE
334
+ * @param {TYPE} type - The event type
335
+ * @param {(event: CadenzaEvent<TYPE, CadenzaEventByType<TYPE>['detail']>) => void} subscriber - The subscriber function
213
336
  * @return {() => void} An unsubscribe function
214
337
  */
215
- on<T = unknown>(type: string, subscriber: (event: CadenzaEvent<T>) => void): () => void;
338
+ on<TYPE extends CadenzaEventType>(type: TYPE, subscriber: (event: CadenzaEvent<TYPE, CadenzaEventByType<TYPE>["detail"]>) => void): () => void;
216
339
  /**
217
340
  * Fetch data from a workbook view.
218
341
  *
219
- * @param {EmbeddingTargetId} source - The workbook view to fetch data from
220
- * @param {DataType} dataType - The data type you want to get back from the server
342
+ * @param {EmbeddingTargetId} source - The workbook view to fetch data from.
343
+ * Currently only table and indicator views are supported.
344
+ * @param {DataType} dataType - The data type you want to get back from the server.
345
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported.
221
346
  * @param {object} options - Options
222
347
  * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
223
348
  * @param {AbortSignal} [options.signal] - A signal to abort the data fetching
224
- * @return {Promise<Response>} A Promise for the fetch response
349
+ * @return {Promise<Response>} A `Promise` for the fetch response
225
350
  * @throws For invalid arguments
226
351
  */
227
352
  fetchData(source: EmbeddingTargetId, dataType: DataType, { parts, signal }?: {
228
353
  parts?: TablePart[] | undefined;
229
354
  signal?: AbortSignal | undefined;
230
- }): Promise<Response>;
355
+ }, ...args: any[]): Promise<Response>;
231
356
  /**
232
357
  * Download data from a workbook view.
233
358
  *
234
359
  * _Note:_ The file name, if not provided, is generated from the name of the workbook view and the current date.
235
360
  *
236
- * @param {EmbeddingTargetId} source - The workbook view to download data from
237
- * @param {DataType} dataType - The data type you want to get back from the server
361
+ * @param {EmbeddingTargetId} source - The workbook view to download data from.
362
+ * Currently only table and indicator views are supported.
363
+ * @param {DataType} dataType - The data type you want to get back from the server.
364
+ * Currently, `"csv"`, `"excel"` and `"json"` are supported.
238
365
  * @param {object} options - Options
239
366
  * @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
240
367
  * @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
@@ -243,16 +370,57 @@ export class CadenzaClient {
243
370
  downloadData(source: EmbeddingTargetId, dataType: DataType, { fileName, parts }: {
244
371
  fileName?: string | undefined;
245
372
  parts?: TablePart[] | undefined;
246
- }): void;
373
+ }, ...args: any[]): void;
247
374
  #private;
248
375
  }
249
376
  /**
250
- * @template [T=unknown]
377
+ * @typedef {'change:selection'
378
+ * | 'drillThrough'
379
+ * | 'editGeometry:ok'
380
+ * | 'editGeometry:update'
381
+ * | 'editGeometry:cancel'
382
+ * | 'objectInfo'
383
+ * | 'selectObjects:ok'
384
+ * | 'selectObjects:cancel'
385
+ * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
386
+ */
387
+ /**
388
+ * @template {CadenzaEventType} T
389
+ * @typedef {T extends 'change:selection' ? CadenzaChangeSelectionEvent
390
+ * : T extends 'drillThrough' ? CadenzaDrillThroughEvent
391
+ * : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent
392
+ * : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent
393
+ * : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent
394
+ * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
395
+ * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
396
+ * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
397
+ * : never
398
+ * } CadenzaEventByType
399
+ */
400
+ /**
401
+ * @template {CadenzaEventType | string} TYPE
402
+ * @template [DETAIL=unknown]
251
403
  * @typedef CadenzaEvent - A Cadenza `postMessage()` event
252
- * @property {string} type - The event type
253
- * @property {T} detail - Optional event details (depending on the event type)
404
+ * @property {TYPE} type - The event type
405
+ * @property {DETAIL} detail - Optional event details (depending on the event type)
406
+ */
407
+ /** @typedef {CadenzaEvent<'change:selection', undefined | {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaChangeSelectionEvent - When the user changed the selection. */
408
+ /**
409
+ * @typedef {CadenzaEvent<'drillThrough', {values: unknown[][]}>} CadenzaDrillThroughEvent - When the user executed a POST message drill-through.
410
+ * <p>
411
+ * The event includes a data row for every item in the workbook selection, each row consisting of the values of
412
+ * the attributes that were selected for the POST message content. If the drill-through was executed from a map
413
+ * view, each row includes the geometry of the selected object as the last value.
414
+ * <p>
415
+ * See also: <a href="../index.html#md:json-representation-of-cadenza-object-data">JSON Representation of Cadenza Object Data</a>
254
416
  */
255
- /** @typedef {CadenzaEvent<{type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
417
+ /** @typedef {CadenzaEvent<'editGeometry:update', {geometry: Geometry}>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. */
418
+ /** @typedef {CadenzaEvent<'editGeometry:ok', {geometry: Geometry}>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
419
+ /** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
420
+ /** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
421
+ /** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number, formattedValues: Record<string, string>}[]}>} CadenzaObjectInfoEvent - When the user opened the object info flyout. */
422
+ /** @typedef {CadenzaEvent<'selectObjects:ok', {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection. */
423
+ /** @typedef {CadenzaEvent<'selectObjects:cancel'>} CadenzaSelectObjectsCancelEvent - When the user cancelled the selection. */
256
424
  export class AbortError extends DOMException {
257
425
  constructor();
258
426
  }
@@ -271,15 +439,39 @@ export class CadenzaError extends Error {
271
439
  #private;
272
440
  }
273
441
  /**
274
- * - The ID of an embedding target
442
+ * - A specific `string` type that is not assignable from another string
443
+ *
444
+ * The idea is to have a specific type e.g. for the {@link EmbeddingTargetId } instead of a plain `string`.
445
+ * You don't need to _actually_ add that `__type` property. In TS code, just use a
446
+ * [type assertion](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions)
447
+ * (e.g. `cadenzaClient.show('{embeddingTargetId}' as EmbeddingTargetId)`).
448
+ */
449
+ export type OpaqueString<T extends string> = string & {
450
+ __type: T;
451
+ };
452
+ /**
453
+ * - The ID of a Cadenza embedding target
454
+ *
455
+ * Embedding targets are called πŸ‡©πŸ‡ͺ "Einbettbarer Inhalt" / πŸ‡ΊπŸ‡Έ "Embeddable content" throughout the Cadenza UI and help.
456
+ * They're managed within the respective workbook:
457
+ *
458
+ * - πŸ‡©πŸ‡ͺ "Mehr" > "Arbeitsmappe verwalten" > "Einbettung"
459
+ * - πŸ‡ΊπŸ‡Έ "More" > "Manage workbook" > "Embedding"
460
+ *
461
+ * The name of an embedding target (as entered in the UI) is its ID.
275
462
  */
276
- export type EmbeddingTargetId = string;
463
+ export type EmbeddingTargetId = OpaqueString<'EmbeddingTargetId'>;
277
464
  /**
278
465
  * - The ID of a navigator item
279
466
  */
280
- export type GlobalId = string;
467
+ export type GlobalId = OpaqueString<'GlobalId'>;
281
468
  /**
282
469
  * - A tuple qualifying a Cadenza external link
470
+ *
471
+ * You get the `repositoryName` and `externalLinkId` from the URL of the external link's page in the Cadenza management center:
472
+ * ```
473
+ * {baseUrl}/admin/repositories/{repositoryName}/external-links/{externalLinkId}?...
474
+ * ```
283
475
  */
284
476
  export type ExternalLinkKey = {
285
477
  /**
@@ -291,6 +483,11 @@ export type ExternalLinkKey = {
291
483
  */
292
484
  externalLinkId: string;
293
485
  };
486
+ /**
487
+ * - Identifies a layer within a workbook map view
488
+ * using the print names of the layer and - if the layer is grouped - its ancestors
489
+ */
490
+ export type WorkbookLayerPath = string[];
294
491
  /**
295
492
  * - A well-known Cadenza page
296
493
  */
@@ -308,8 +505,8 @@ export type OperationMode = 'normal' | 'simplified';
308
505
  * - The name of a Cadenza UI feature
309
506
  *
310
507
  * _Note:_ Supported features are:
311
- * * 'workbook-design' - The workbook designer
312
- * * 'workbook-view-management' - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
508
+ * * `"workbook-design"` - The workbook designer
509
+ * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
313
510
  */
314
511
  export type UiFeature = 'workbook-design' | 'workbook-view-management';
315
512
  /**
@@ -333,33 +530,101 @@ export type GeometryType = 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineStr
333
530
  export type Extent = [number, number, number, number];
334
531
  /**
335
532
  * - A data type
533
+ *
534
+ * See [JSON Representation of Cadenza Object Data](../index.html#md:json-representation-of-cadenza-object-data) for JSON data.
336
535
  */
337
- export type DataType = 'csv' | 'excel' | 'json' | 'pdf';
536
+ export type DataType = 'csv' | 'excel' | 'json' | 'pdf' | 'png';
338
537
  /**
339
538
  * - A part of a table to export
340
539
  */
341
540
  export type TablePart = 'columns' | 'values' | 'totals';
342
541
  /**
343
542
  * - Filter variable names and values
543
+ *
544
+ * Variables of type String, Integer, Long, Double and Date can be set.
545
+ *
546
+ * _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)),
547
+ * for Long variables, the API is currently limited to the Double value range.
344
548
  */
345
- export type FilterVariables = Record<string, string | number | Date>;
549
+ export type FilterVariables = Record<string, string | string[] | number | Date | null>;
550
+ /**
551
+ * - An event type to subscribe to using {@link CadenzaClienton }
552
+ */
553
+ export type CadenzaEventType = 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'selectObjects:ok' | 'selectObjects:cancel';
554
+ export type CadenzaEventByType<T extends CadenzaEventType> = T extends 'change:selection' ? CadenzaChangeSelectionEvent : T extends 'drillThrough' ? CadenzaDrillThroughEvent : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent : T extends 'objectInfo' ? CadenzaObjectInfoEvent : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent : never;
346
555
  /**
347
556
  * - A Cadenza `postMessage()` event
348
557
  */
349
- export type CadenzaEvent<T = unknown> = {
558
+ export type CadenzaEvent<TYPE extends string, DETAIL = unknown> = {
350
559
  /**
351
560
  * - The event type
352
561
  */
353
- type: string;
562
+ type: TYPE;
354
563
  /**
355
564
  * - Optional event details (depending on the event type)
356
565
  */
357
- detail: T;
566
+ detail: DETAIL;
358
567
  };
568
+ /**
569
+ * - When the user changed the selection.
570
+ */
571
+ export type CadenzaChangeSelectionEvent = CadenzaEvent<'change:selection', undefined | {
572
+ layer: string[];
573
+ values: unknown[][];
574
+ }>;
575
+ /**
576
+ * - When the user executed a POST message drill-through.
577
+ * <p>
578
+ * The event includes a data row for every item in the workbook selection, each row consisting of the values of
579
+ * the attributes that were selected for the POST message content. If the drill-through was executed from a map
580
+ * view, each row includes the geometry of the selected object as the last value.
581
+ * <p>
582
+ * See also: <a href="../index.html#md:json-representation-of-cadenza-object-data">JSON Representation of Cadenza Object Data</a>
583
+ */
584
+ export type CadenzaDrillThroughEvent = CadenzaEvent<'drillThrough', {
585
+ values: unknown[][];
586
+ }>;
587
+ /**
588
+ * - When the user changed the geometry.
589
+ */
590
+ export type CadenzaEditGeometryUpdateEvent = CadenzaEvent<'editGeometry:update', {
591
+ geometry: Geometry;
592
+ }>;
593
+ /**
594
+ * - When the user submitted the geometry.
595
+ */
596
+ export type CadenzaEditGeometryOkEvent = CadenzaEvent<'editGeometry:ok', {
597
+ geometry: Geometry;
598
+ }>;
599
+ /**
600
+ * - When the user cancelled the geometry editing.
601
+ */
602
+ export type CadenzaEditGeometryCancelEvent = CadenzaEvent<'editGeometry:cancel'>;
359
603
  /**
360
604
  * - An error event that is mapped to a {@link CadenzaError }
361
605
  */
362
- export type CadenzaErrorEvent = CadenzaEvent<{
606
+ export type CadenzaErrorEvent = CadenzaEvent<'error', {
363
607
  type: string;
364
608
  message?: string;
365
609
  }>;
610
+ /**
611
+ * - When the user opened the object info flyout.
612
+ */
613
+ export type CadenzaObjectInfoEvent = CadenzaEvent<'objectInfo', {
614
+ layer: string[];
615
+ objectInfos: {
616
+ selectionIndex: number;
617
+ formattedValues: Record<string, string>;
618
+ }[];
619
+ }>;
620
+ /**
621
+ * - When the user submitted the selection.
622
+ */
623
+ export type CadenzaSelectObjectsOkEvent = CadenzaEvent<'selectObjects:ok', {
624
+ layer: string[];
625
+ values: unknown[][];
626
+ }>;
627
+ /**
628
+ * - When the user cancelled the selection.
629
+ */
630
+ export type CadenzaSelectObjectsCancelEvent = CadenzaEvent<'selectObjects:cancel'>;