Releases: ItemConsulting/enonic-types
Add types for notification library
This release adds TypeScript types for the Notification Library, which allows developers to send push notifications to users.
Controller types for WebSocket
Add types to controller.ts for handling websocket connections:
- The
WebSocketResponse
interface can be used to initiate a connection - The
WebSocketEvent
type can be used by awebSocketEvent(event: WebSocketEvent)
function in a controller to handle incoming messages and connections. - The
Request.webSocket
constant can be used to check if this is an attempt to open a web socket connection in aget(req: Request)
function.
Add support for admin, cluster and task libraries
Support has been added for the following libraries:
- AdminLibrary
- ClusterLibrary
- TaskLibrary
Remove nullability for portalLib.{getComponent,getContent}
The functions portalLib.getComponent()
and portalLib.getContent()
will not return null
if used in the documented legal places (page, part and layout).
The types for these two functions has now been changed so that they don't return null
!
The functions can return null
if a developer tries to use them in a webapp or error handler, but a null
in these places would probably trigger an exception, which would be good, and stop the developer from using it here at all.
If the developer wants to reuse code between e.g a page controller and the error handler, there is of course nothing stopping them from adding a null check, but the compiler will not enforce this check anymore.
Add TestingLib support and missing methods in NodeLib
- This release adds support for
TestingLibrary
. Though the way to use it is not clear in starter-webpack. NodeLibrary
gets missing functions inRepoConnection
ContentLib.query
gets metadata support with_score
and_sort
fields
Add types for WebsocketLib
Adds support for WebsocketLibrary and improvements to documentation.
Simplify library paths
All import paths changed
The "/lib/
" part of all import
paths has been removed since it gave no value to the developers.
// import { Content } from 'enonic-types/lib/content'; // old style
import { Content } from 'enonic-types/content'; // new style
// import { Component } from 'enonic-types/lib/portal'; // old style
import { Component } from 'enonic-types/portal'; // new style
Note on upgrading
When upgrading to this version, we recommend just doing a replace on all the code in your project, where enonic-types/lib/ becomes enonic-types/