Wiki source code of Live Data API
Last modified by Manuel Leduc on 2026/03/24 09:38
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
4.1 | 1 | {{version since="18.2.0RC1"}} |
| 2 | == ActionDescriptor == | ||
| |
2.1 | 3 | |
| 4 | Describes a live data action. | ||
| |
2.2 | 5 | |
| |
4.1 | 6 | {{code language="typescript"}} |
| |
2.1 | 7 | interface ActionDescriptor { |
| 8 | allowProperty?: string; | ||
| 9 | id: string; | ||
| 10 | } | ||
| 11 | {{/code}} | ||
| 12 | |||
| |
4.1 | 13 | === Properties === |
| |
2.1 | 14 | |
| 15 | * ##id##: The action id. | ||
| 16 | * ##allowProperty##: An optional boolean property id. This property is going to be used to determine if the action is allowed for a given entry. | ||
| 17 | |||
| |
4.1 | 18 | == Data == |
| |
2.1 | 19 | |
| 20 | Stores the entries to display (paginated) and the total count of entries. | ||
| 21 | |||
| |
4.1 | 22 | {{code language="typescript"}} |
| |
2.2 | 23 | interface Data { |
| 24 | count: number; | ||
| 25 | entries: Values[]; | ||
| 26 | } | ||
| 27 | {{/code}} | ||
| 28 | |||
| |
4.1 | 29 | === Properties === |
| |
2.1 | 30 | |
| 31 | * ##count##: The total number of entries. | ||
| 32 | * ##entries##: The list of entries to display (paginated). | ||
| 33 | |||
| |
4.1 | 34 | == DisplayerDescriptor == |
| 35 | |||
| |
3.1 | 36 | |
| 37 | Holds the displayer configuration. | ||
| |
2.1 | 38 | |
| |
4.1 | 39 | {{code language="typescript"}} |
| |
3.1 | 40 | interface DisplayerDescriptor { |
| |
2.1 | 41 | id: string; |
| 42 | } | ||
| |
3.1 | 43 | {{/code}} |
| |
2.1 | 44 | |
| |
4.1 | 45 | === Properties === |
| |
2.1 | 46 | |
| |
3.1 | 47 | * ##id##: The displayer id. |
| |
2.1 | 48 | |
| |
4.1 | 49 | == EntryDescriptor == |
| |
3.1 | 50 | |
| 51 | Describes a live data entry. | ||
| 52 | |||
| |
4.1 | 53 | {{code language="typescript"}} |
| |
3.1 | 54 | interface EntryDescriptor { |
| |
2.1 | 55 | idProperty: string; |
| 56 | } | ||
| |
3.1 | 57 | {{/code}} |
| |
2.1 | 58 | |
| |
4.1 | 59 | === Properties === |
| |
3.1 | 60 | |
| 61 | * ##idProperty##: The id of the described property. | ||
| 62 | |||
| |
4.1 | 63 | == Filter == |
| |
3.1 | 64 | |
| 65 | A set of constraints to apply to a given property. | ||
| 66 | |||
| |
4.1 | 67 | {{code language="typescript"}} |
| |
3.1 | 68 | interface Filter { |
| |
2.1 | 69 | constraints: QueryConstraint[]; |
| 70 | matchAll: boolean; | ||
| 71 | property: string; | ||
| 72 | } | ||
| |
3.1 | 73 | {{/code}} |
| |
2.1 | 74 | |
| |
4.1 | 75 | === Properties === |
| 76 | |||
| 77 | |||
| |
3.1 | 78 | * ##constraints##: The set of constraints to apply on the query. |
| 79 | * ##matchAll##: When true, all the constraints must be true for the filter to allow the entry to be displayed. When false, only on of the constraint must be true. | ||
| 80 | * ##property##: The property of filter. | ||
| 81 | |||
| |
4.1 | 82 | |
| 83 | == FilterDescriptor == | ||
| 84 | |||
| |
3.1 | 85 | |
| 86 | Holds the filter configuration. | ||
| 87 | |||
| |
4.1 | 88 | {{code language="typescript"}} |
| |
3.1 | 89 | interface FilterDescriptor { |
| |
2.1 | 90 | defaultOperator: string; |
| 91 | id: string; | ||
| 92 | operators: OperatorDescriptor[]; | ||
| 93 | } | ||
| |
3.1 | 94 | {{/code}} |
| |
2.1 | 95 | |
| |
4.1 | 96 | === Properties === |
| 97 | |||
| 98 | |||
| |
3.1 | 99 | * ##defaultOperator##: The default filter operator for this filter. |
| 100 | * ##id##: The filter id. | ||
| 101 | * ##operators##: The list of operators supported by this filter. | ||
| 102 | |||
| |
4.1 | 103 | == LayoutDescriptor == |
| |
3.1 | 104 | |
| 105 | Holds the layout configuration. | ||
| 106 | |||
| |
4.1 | 107 | {{code language="typescript"}} |
| |
3.1 | 108 | interface LayoutDescriptor { |
| |
2.1 | 109 | id: string; |
| 110 | } | ||
| |
3.1 | 111 | {{/code}} |
| |
2.1 | 112 | |
| |
4.1 | 113 | === Properties === |
| |
3.1 | 114 | |
| 115 | * ##id##: The id of the layout. | ||
| 116 | |||
| |
4.1 | 117 | == LiveDataSource == |
| |
3.1 | 118 | |
| 119 | The component that provides the live data entries and their metadata. | ||
| 120 | |||
| |
4.1 | 121 | {{code language="typescript"}} |
| |
3.1 | 122 | interface LiveDataSource { |
| |
2.1 | 123 | getEntries(query: Query): Promise<Data>; |
| |
3.1 | 124 | updateEntry( |
| 125 | source: Source, | ||
| 126 | entryId: string, | ||
| 127 | values: unknown, | ||
| 128 | ): Promise<void>; | ||
| 129 | updateEntryProperty( | ||
| 130 | source: Source, | ||
| 131 | entryId: string, | ||
| 132 | propertyId: string, | ||
| 133 | value: unknown, | ||
| 134 | ): Promise<void>; | ||
| |
2.1 | 135 | } |
| |
3.1 | 136 | {{/code}} |
| |
2.1 | 137 | |
| |
4.1 | 138 | === Methods === |
| |
3.1 | 139 | |
| 140 | * ##getEntries##: Fetch the entries from a given live data source based on the provided query. The result is a paginated results plus the total number of entries. | ||
| 141 | * ##updateEntry##: the query of apply when fetching the entries | ||
| 142 | * ##updateEntryProperty##: a promise with the fetched data | ||
| 143 | |||
| |
4.1 | 144 | == Logic == |
| |
3.1 | 145 | |
| 146 | Present the public API of the logic used inside the Live Data UI. It provides the operations and data to display Live Datas. It is build to be shared by most of the UI elements of a Live Data. | ||
| 147 | |||
| |
4.1 | 148 | {{code language="typescript"}} |
| |
3.1 | 149 | interface Logic { |
| 150 | currentLayoutId?: Ref<string, string>; | ||
| 151 | data?: { | ||
| 152 | data: { count: number; entries: Values[] }; | ||
| 153 | id: number; | ||
| 154 | meta: { | ||
| 155 | actions: { allowProperty?: string; id: string }[]; | ||
| 156 | defaultDisplayer: string; | ||
| 157 | defaultLayout: string; | ||
| 158 | displayers: { id: string }[]; | ||
| 159 | entryDescriptor: { idProperty: string }; | ||
| 160 | filters: { | ||
| 161 | defaultOperator: string; | ||
| 162 | id: string; | ||
| 163 | operators: { id: string; name: string }[]; | ||
| 164 | }[]; | ||
| 165 | layouts: { id: string }[]; | ||
| 166 | propertyDescriptors: { | ||
| 167 | displayer: { id: string }; | ||
| 168 | editable?: boolean; | ||
| 169 | filter: { | ||
| 170 | constraints: { operator: string; value: unknown }[]; | ||
| 171 | matchAll: boolean; | ||
| 172 | property: string; | ||
| 173 | }; | ||
| 174 | filterable?: boolean; | ||
| 175 | id: string; | ||
| 176 | sortable?: boolean; | ||
| 177 | type: string; | ||
| 178 | visible?: boolean; | ||
| 179 | }[]; | ||
| 180 | propertyTypes: { | ||
| 181 | displayer: { id: string }; | ||
| 182 | editable?: boolean; | ||
| 183 | filter: { | ||
| 184 | constraints: { operator: string; value: unknown }[]; | ||
| 185 | matchAll: boolean; | ||
| 186 | property: string; | ||
| 187 | }; | ||
| 188 | filterable?: boolean; | ||
| 189 | id: string; | ||
| 190 | sortable?: boolean; | ||
| 191 | type: string; | ||
| 192 | visible?: boolean; | ||
| 193 | }[]; | ||
| 194 | selection: { enabled: boolean }; | ||
| 195 | }; | ||
| 196 | query: { | ||
| 197 | filters: { | ||
| 198 | constraints: { operator: string; value: unknown }[]; | ||
| 199 | matchAll: boolean; | ||
| 200 | property: string; | ||
| 201 | }[]; | ||
| 202 | limit: number; | ||
| 203 | offset: number; | ||
| 204 | properties: string[]; | ||
| 205 | sort: { descending: boolean; property: string }[]; | ||
| 206 | source: { id: string; [key: string]: string }; | ||
| 207 | }; | ||
| 208 | }; | ||
| 209 | addFilter( | ||
| 210 | property: string, | ||
| 211 | operator: unknown, | ||
| 212 | value: string, | ||
| 213 | index: number, | ||
| 214 | ): Promise<void>; | ||
| |
2.1 | 215 | addSort(property: string, descending: boolean | undefined): Promise<void>; |
| 216 | changeLayout(layoutId: string): void; | ||
| |
3.1 | 217 | filter( |
| 218 | property: string, | ||
| 219 | index: number, | ||
| 220 | filterEntry: { index: number }, | ||
| 221 | operator: { filterOperator?: unknown; skipFetch?: boolean }, | ||
| 222 | ): Promise<void>; | ||
| |
2.1 | 223 | getEntryId(entry: Values): string | undefined; |
| 224 | getPageCount(): number; | ||
| 225 | isContentTrusted(): boolean; | ||
| 226 | onEvent(event: string, callback: (e: Event) => void): void; | ||
| |
3.1 | 227 | onEventWhere( |
| 228 | eventName: string, | ||
| 229 | condition: object | ((p: unknown) => boolean), | ||
| 230 | callback: (e: Event) => void, | ||
| 231 | ): void; | ||
| |
2.1 | 232 | registerPanel(panel: Panel): void; |
| 233 | removeFilter(property: string, index: number): Promise<void>; | ||
| 234 | removeSort(property: string): Promise<void>; | ||
| 235 | reorderSort(propertyId: string, toIndex: number): void; | ||
| 236 | setElement(element: HTMLElement): void; | ||
| |
3.1 | 237 | setValues(entryId: { entryId: string; values: unknown }): Promise<unknown>; |
| |
2.1 | 238 | sort(property: string, level: number, descending?: boolean): Promise<void>; |
| 239 | translationsLoaded(): Promise<boolean>; | ||
| 240 | triggerEvent(eventName: string, eventData?: object): void; | ||
| 241 | updateEntries(): Promise<void>; | ||
| 242 | } | ||
| |
3.1 | 243 | {{/code}} |
| |
2.1 | 244 | |
| |
4.1 | 245 | === Properties === |
| |
3.1 | 246 | |
| |
4.1 | 247 | * ##currentLayoutId#: The id of the current layout.## |
| 248 | * ##data#: The Live Data data, fetch from a source.## | ||
| |
3.1 | 249 | |
| |
4.1 | 250 | === Methods === |
| |
3.1 | 251 | |
| 252 | * ##addFilter##: Add new filter entry, shorthand of filter: | ||
| 253 | * ##addSort##: Add new sort entry, shorthand of sort: If the property is already sorting, does nothing | ||
| 254 | * ##changeLayout##: Load a layout, or default layout if none specified | ||
| 255 | * ##filter##: Update filter configuration based on parameters, then fetch new data. | ||
| 256 | * ##getEntryId##: Return the id of the given entry. | ||
| 257 | * ##getPageCount##: Get total number of pages | ||
| 258 | * ##isContentTrusted##: When true, the content is trusted. When false, the content is not trusted and will be sanitized. | ||
| 259 | * ##onEvent##: Listen for an event. | ||
| 260 | * ##onEventWhere##: Listen for custom events, matching certain conditions. | ||
| 261 | * ##registerPanel##: Registers a panel. | ||
| 262 | * ##removeFilter##: Remove a filter entry in the configuration, then fetch new data | ||
| 263 | * ##removeSort##: Remove a sort entry, shorthand of sort: | ||
| 264 | * ##reorderSort##: Move a sort entry to a certain index in the query sort list | ||
| 265 | * ##setElement##: Set the root element of the Live Data. | ||
| 266 | * ##setValues##: Update the entry with the values object passed in parameter | ||
| 267 | * ##sort##: Update sort configuration based on parameters, then fetch new data | ||
| 268 | * ##translationsLoaded##: A promise completing when the translations are loaded. It can contain true if the translations loaded successfully, false otherwise. | ||
| 269 | * ##triggerEvent##: Send custom events. The livedata object reference is automatically added. | ||
| 270 | * ##updateEntries##: Trigger a refresh of the Live Data. | ||
| 271 | |||
| |
4.1 | 272 | == LogicData == |
| |
3.1 | 273 | |
| 274 | The data stored in a Logic object. It contains the metadata of a Live Data, the query used to fetch the data, and the data themselves. | ||
| 275 | |||
| |
4.1 | 276 | {{code language="typescript"}} |
| |
3.1 | 277 | interface LogicData { |
| |
2.1 | 278 | data: Data; |
| 279 | id: number; | ||
| 280 | meta: Meta; | ||
| 281 | query: Query; | ||
| 282 | } | ||
| |
3.1 | 283 | {{/code}} |
| |
2.1 | 284 | |
| |
4.1 | 285 | === Properties === |
| |
3.1 | 286 | |
| 287 | * ##data##: Holds the data | ||
| 288 | * ##id##: The id of a livedata | ||
| 289 | * ##meta##: The metadata of a Live Data, stores the descriptor for the displayers, filters, layout, or actions. | ||
| 290 | * ##query##: Holds the query parameters used to retrieve the Live Data data. | ||
| 291 | |||
| |
4.1 | 292 | == Meta == |
| |
3.1 | 293 | |
| 294 | Describes the configuration used to display the live data. | ||
| 295 | |||
| |
4.1 | 296 | {{code language="typescript"}} |
| |
3.1 | 297 | interface Meta { |
| |
2.1 | 298 | actions: ActionDescriptor[]; |
| 299 | defaultDisplayer: string; | ||
| 300 | defaultLayout: string; | ||
| 301 | displayers: DisplayerDescriptor[]; | ||
| 302 | entryDescriptor: EntryDescriptor; | ||
| 303 | filters: FilterDescriptor[]; | ||
| 304 | layouts: LayoutDescriptor[]; | ||
| |
3.1 | 305 | propertyDescriptors: PropertyDescriptor[]; |
| 306 | propertyTypes: PropertyDescriptor[]; | ||
| 307 | selection: { enabled: boolean }; | ||
| |
2.1 | 308 | } |
| |
3.1 | 309 | {{/code}} |
| |
2.1 | 310 | |
| |
4.1 | 311 | === Properties === |
| |
3.1 | 312 | |
| 313 | * ##actions##: The descriptors of supported live data actions | ||
| 314 | * ##defaultDisplayer##: The default displayer used to display live data properties. | ||
| 315 | * ##defaultLayout##: The default layout used to display the live data | ||
| 316 | * ##displayers##: The list of known property displayers | ||
| 317 | * ##entryDescriptor##: The descriptor of the live data entries. | ||
| 318 | * ##filters##: The list of known filter widgets. | ||
| 319 | * ##layouts##: Sets the list of supported layouts. | ||
| 320 | * ##propertyDescriptors##: The list of known properties. | ||
| 321 | * ##propertyTypes##: The list of known property types. | ||
| 322 | * ##selection##: The live data entry selection. Note: the selection implementation is currently incomplete. | ||
| 323 | |||
| |
4.1 | 324 | == OperatorDescriptor == |
| |
3.1 | 325 | |
| 326 | An operator to use when filtering the live data. | ||
| 327 | |||
| |
4.1 | 328 | {{code language="typescript"}} |
| |
3.1 | 329 | interface OperatorDescriptor { |
| |
2.1 | 330 | id: string; |
| 331 | name: string; | ||
| 332 | } | ||
| |
3.1 | 333 | {{/code}} |
| |
2.1 | 334 | |
| |
4.1 | 335 | === Properties === |
| |
3.1 | 336 | |
| 337 | * ##id##: The operator id | ||
| 338 | * ##name##: The operator pretty name. | ||
| 339 | |||
| |
4.1 | 340 | == Panel == |
| |
3.1 | 341 | |
| 342 | Holds all the information required to describe a panel. | ||
| 343 | |||
| |
4.1 | 344 | {{code language="typescript"}} |
| |
3.1 | 345 | interface Panel { |
| |
2.1 | 346 | component: string; |
| 347 | container?: Element; | ||
| 348 | icon: string; | ||
| 349 | id: string; | ||
| 350 | name: string; | ||
| 351 | order: number; | ||
| 352 | title: string; | ||
| 353 | } | ||
| |
3.1 | 354 | {{/code}} |
| |
2.1 | 355 | |
| |
4.1 | 356 | === Properties === |
| |
3.1 | 357 | |
| 358 | |||
| 359 | * ##component##: the component id of the panel, should be "LiveDataAdvancedPanelExtension" for extension panels | ||
| 360 | * ##container?##: the Element that shall be attached to the extension panel's body, this should contain the main UI | ||
| 361 | * ##icon##: the name of the icon for the menu and the title of the panel | ||
| 362 | * ##id##: the id of the panel, must be unique among all panels, also used as suffix of the class on the panel | ||
| 363 | * ##name##: the name that shall be shown in the menu | ||
| 364 | * ##order##: the ordering number, panels are sorted by this number in ascending order | ||
| 365 | * ##title##: the title that shall be displayed in the title bar of the panel | ||
| 366 | |||
| |
4.1 | 367 | == PropertyDescriptor == |
| |
3.1 | 368 | |
| 369 | Describes how the user interacts with a given property. | ||
| 370 | |||
| |
4.1 | 371 | {{code language="typescript"}} |
| |
3.1 | 372 | interface PropertyDescriptor { |
| |
2.1 | 373 | displayer: DisplayerDescriptor; |
| 374 | editable?: boolean; | ||
| 375 | filter: Filter; | ||
| 376 | filterable?: boolean; | ||
| 377 | id: string; | ||
| 378 | sortable?: boolean; | ||
| 379 | type: string; | ||
| 380 | visible?: boolean; | ||
| 381 | } | ||
| |
3.1 | 382 | {{/code}} |
| |
2.1 | 383 | |
| |
4.1 | 384 | === Properties === |
| |
3.1 | 385 | |
| 386 | * ##displayer##: The display of the property. | ||
| 387 | * ##editable?##: true when the property is editable. | ||
| 388 | * ##filter##: The filter of the property. | ||
| 389 | * ##filterable?##: true when the property is filterable. | ||
| 390 | * ##id##: The property id. | ||
| 391 | * ##sortable?##: true when the property is sortable. | ||
| 392 | * ##type##: The property type. | ||
| 393 | |||
| |
4.1 | 394 | == Query == |
| |
3.1 | 395 | |
| 396 | The query used to get the live data. | ||
| 397 | |||
| |
4.1 | 398 | {{code language="typescript"}} |
| |
3.1 | 399 | interface Query { |
| |
2.1 | 400 | filters: Filter[]; |
| 401 | limit: number; | ||
| 402 | offset: number; | ||
| 403 | properties: string[]; | ||
| 404 | sort: SortEntry[]; | ||
| 405 | source: Source; | ||
| 406 | } | ||
| |
3.1 | 407 | {{/code}} |
| |
2.1 | 408 | |
| |
4.1 | 409 | === Properties === |
| |
3.1 | 410 | |
| 411 | * ##filters##: The filters to apply on the property values. | ||
| 412 | * ##limit##: The number of entries to fetch (the page size). | ||
| 413 | * ##offset##: The index where the current page of entries starts | ||
| 414 | * ##properties##: The list of properties whose values we want to fetch. | ||
| 415 | * ##sort##: The list of properties to sort on, along with their corresponding sort direction. | ||
| 416 | * ##source##: Where to take the data from | ||
| 417 | |||
| |
4.1 | 418 | == QueryConstraint == |
| |
3.1 | 419 | |
| 420 | A constraint to apply to a property value. | ||
| 421 | |||
| |
4.1 | 422 | {{code language="typescript"}} |
| |
3.1 | 423 | interface QueryConstraint { |
| |
2.1 | 424 | operator: string; |
| 425 | value: unknown; | ||
| 426 | } | ||
| |
3.1 | 427 | {{/code}} |
| |
2.1 | 428 | |
| |
4.1 | 429 | === Properties === |
| |
3.1 | 430 | |
| 431 | * ##operator##: The operation id (e.g., "equals") | ||
| 432 | * ##value##: An arbitrary value to apply on the operator (e.g., a string to use for the equals comparion). | ||
| 433 | |||
| |
4.1 | 434 | == SortEntry == |
| |
3.1 | 435 | |
| 436 | A sort entry. | ||
| 437 | |||
| |
4.1 | 438 | {{code language="typescript"}} |
| |
3.1 | 439 | interface SortEntry { |
| |
2.1 | 440 | descending: boolean; |
| 441 | property: string; | ||
| 442 | } | ||
| |
3.1 | 443 | {{/code}} |
| |
2.1 | 444 | |
| |
4.1 | 445 | === Properties === |
| |
2.1 | 446 | |
| |
3.1 | 447 | * ##descending##: When true sort descending, or ascending when false. |
| 448 | * ##property##: The id of the property to sort. | ||
| 449 | |||
| |
4.1 | 450 | == Source == |
| |
3.1 | 451 | |
| 452 | Specifies where to take the data from. Represents the "from" clause. | ||
| 453 | |||
| |
4.1 | 454 | {{code language="typescript"}} |
| |
3.1 | 455 | Source: { id: string } & { [key: string]: string } |
| |
2.1 | 456 | {{/code}} |
| |
3.1 | 457 | |
| |
4.1 | 458 | == Values == |
| |
3.1 | 459 | |
| 460 | The values of an entry, an arbitrary maps of key and values. | ||
| 461 | |||
| |
4.1 | 462 | {{code language="typescript"}} |
| |
3.1 | 463 | Values: { [key: string]: string } |
| 464 | {{/code}} | ||
| |
4.1 | 465 | {{/version}} |