Releases: ItemConsulting/enonic-types
Add types for Export Library
New libraries supported
Support has been added for the following libraries:
- ExportLibrary (XP 7.8.0)
Other
- Narrower types for Principal has been added using template litterals to enforce string shapes.
Expose types trough XP modules
Big changes
- Types must now be imported from the corresponding the XP-modules (like
"/lib/xp/content"
), instead of being imported from a separate library (like"enonic-types/content"
).
This is a cleaner approach, since the types now lives with the functions that use them. "enonic-types/controller"
doesn't have a corresponding library since models the shape of the internal structures in XP. So all the types there has been made available on the global scope under theXP
namespace.
Now you can just useXP.Request
without doing any imports.
To use this release you will need to change all the imports in your code like this:
- import { Request, Response } from "enonic-types/controller";
- import { get } from "/lib/xp/content";
- import { Content } from "enonic-types/content";
+ import { get, Content } from "/lib/xp/content";
- export function post(req: Request): Response {
+ export function post(req: XP.Request): XP.Response {
const content: Content = get({
key: req.params.key!
})
...
}
As you can see, this will clean up imports a bit, and logically group functions and their types together.
From now on you will never do any import ... from "enonic-types/..."
directly in your code!
The one exception to this is the import from "enonic-types/libs"
to configure __non_webpack_require__
(but I recommend using JavaScript modules import
keyword instead of __non_webpack_require__
).
Protip: In the upcoming TypeScript 4.5 release we will be able to use type
modifiers on import names like this:
import { get, type Content } from "/lib/xp/content";
New features
- A new global
XP.Controller
type has been added. You can use it if you prefer arrow functions for your controllers. It can be used like this:
- import { Request, Response } from "enonic-types/controller";
- export const get = (req: Request): Response => {
+ export const get: XP.Controller = (req) => {
}
Fix types in SchedulerLib
Improve types for GraphQL lib
Thanks to @itemodahl for providing a fix for the GraphQL lib.
Support RouterLib@3.0.0 changes
Changes:
- Update RouterLib to support
string | Array<string>
aspattern
parameter
Fix to authLib `getProfile`
Bugfixes
- Fix from @maxYurchenko that corrects
authLib.getProfile()
params
Updates to Repo and Node libraries
Small release with some fixes to types for NodeLibrary and RepoLibrary
Add types for Auditlog library
New libraries supported
Support has been added for the following libraries:
- AuditlogLibrary (XP 7.2.0)
Other
- Deprecated CronLib in favor of SchedulerLibrary since 7.7.0
- Small change to
MultiRepoConnection
in NodeLib - Extract
CustomSelectorServiceRequestParams
fromCustomSelectorServiceRequest
GraphQL and XP 7.7.0 support
New libraries supported
Support has been added for the following libraries:
- SchedulerLibrary (XP 7.7.0)
- GraphQLLibrary
- GuillotineLibrary
- SqlLibrary
Other
- Deprecated TaskLib functions
submit
andsubmitNamed
for 7.7.0, and addedexecuteFunction
andsubmitTask
as replacements - Added
min
,max
andcount
aggregations for 7.7.0 - Added
imageWidths
toprocessHtml
for 7.7.0
Add QRCode, Mustache, XSLT libs
New libraries supported
Support has been added for the following libraries:
- QRCode
- Mustache
- XSLT
Improvements
- Remove
readonly
statements to enable mutation of more objects (#15)
Bug fixes
- Fix type for
headers
in params for mailLib (#14)
Thanks to @maxYurchenko for his contributions!