All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
15.2.0 (2024-09-27)
- exports optional 'Snippet' type used for strongly typed modelling (96ef2d5)
15.1.1 (2024-09-27)
- re-exports IContentItemElements type (ddc570f)
15.1.0 (2024-09-26)
- Adds support for constraining item element properties using pre-defined codenames type (c7b16b7)
- updates deps (03fdc22)
15.0.0 (2024-09-16)
- updates deps (7d0618c)
15.0.0-0 (2024-09-10)
- Removes parser & rich text resolver. To work with RTE use the newer and better
@kontent-ai/rich-text-resolver
library instead. - Removes
propertyName
resolver configuration. All elements are now referenced only by their codenames present in Kontent.ai
- Adds narrowing types for Taxonomy & Multiple choice elements (3118752)
- Adds optional generic types to
IContentItem
narrowing down available values of system attributes (8c894af) - Makes
RichTextElement
take generic parameter narrowing down allowed types of linked items (68b31a8) - Removes
propertyName
resolver configuration. All elements are now referenced only by their codenames present in Kontent.ai (7ef5951) - Removes parser & rich text resolver. To work with RTE use the newer and better
@kontent-ai/rich-text-resolver
library instead. (2bd30c3) - updates deps (82c2c11)
In < 15.0.0
versions of this SDK you were able to resolve RTE elements like this:
import { createRichTextHtmlResolver, createDeliveryClient, linkedItemsHelper } from '@kontent-ai/delivery-sdk';
export type Movie = IContentItem<{
plot: Elements.RichTextElement;
}>;
export type Actor = IContentItem<{
firstName: Elements.RichTextElement;
}>;
// get content item with rich text element
const response = (
await createDeliveryClient({ environmentId: '<YOUR_ENVIRONMENT_ID>' }).item<Movie>('itemCodename').toPromise()
).data;
// get rich text element
const richTextElement = response.item.plot;
// resolve HTML
const resolvedRichText = createRichTextHtmlResolver().resolveRichText({
element: richTextElement,
linkedItems: linkedItemsHelper.convertLinkedItemsToArray(response.data.linkedItems),
imageResolver: (imageId, image) => {
return {
imageHtml: `<img class="xImage" src="${image?.url}">`,
// alternatively you may return just url
imageUrl: 'customUrl'
};
},
urlResolver: (linkId, linkText, link) => {
return {
linkHtml: `<a class="xLink">${link?.link?.urlSlug}</a>`,
// alternatively you may return just url
linkUrl: 'customUrl'
};
},
contentItemResolver: (itemId, contentItem) => {
if (contentItem && contentItem.system.type === 'actor') {
const actor = contentItem as Actor;
return {
contentItemHtml: `<div class="xClass">${actor.elements.firstName.value}</div>`
};
}
return {
contentItemHtml: ''
};
}
});
const resolvedHtml = resolvedRichText.html;
But since this resolver is now removed in >= 15.0.0
you need to resolve RTE using the @kontent-ai/rich-text-resolver
package:
import { createDeliveryClient, Elements, IContentItem } from '@kontent-ai/delivery-sdk';
import { PortableTextOptions, toHTML } from '@portabletext/to-html';
import { nodeParse, transformToPortableText, resolveTable, resolveImage } from '@kontent-ai/rich-text-resolver';
type Movie = IContentItem<{
title: Elements.TextElement;
plot: Elements.RichTextElement<Actor>;
}>;
type Actor = IContentItem<{
first_name: Elements.RichTextElement;
}>;
const itemResponse = await createDeliveryClient({
environmentId: 'da5abe9f-fdad-4168-97cd-b3464be2ccb9'
})
.item<Movie>('warrior')
.toPromise();
const richTextElement = itemResponse.data.item.elements.plot;
const linkedItems = Object.values(itemResponse.data.linkedItems);
const parsedTree = nodeParse(richTextElement.value);
const portableText = transformToPortableText(parsedTree);
const portableTextComponents: PortableTextOptions = {
components: {
types: {
image: ({ value }) => {
return resolveImage(value, (image) => {
return `<img class="xImage" src="${image.asset.url}">`;
});
},
component: ({ value }) => {
const linkedItem = linkedItems.find((item) => item.system.codename === value.component._ref);
switch (linkedItem?.system.type) {
case 'actor': {
const actor = linkedItem as Actor;
return `<div class="xClass">${actor.elements.first_name.value}</div>`;
}
default: {
return `Resolver for type ${linkedItem?.system.type} not implemented.`;
}
}
},
table: ({ value }) => {
// default impl
return resolveTable(value, toHTML);
}
},
marks: {
internalLink: ({ children, value }) => {
return `<a class="xLink" href="https://yourdomain.com/actor/${value.reference._ref}">${children}</a>`;
}
}
}
};
const resolvedHtml = toHTML(portableText, portableTextComponents);
14.11.0 (2024-08-15)
- updates deps (& fixes Axios vulnerability), updates eslint config (ba49770)
14.10.0 (2024-06-28)
- updates deps (769173b)
14.9.0 (2024-04-29)
- updates deps (f6c2a2f)
14.8.0 (2024-03-06)
- adds support for 'excludeElements' parameter (fixes #389) (64a2b17)
- updates deps, adds clean script, updates engine version to >= v18 (6135b03)
14.7.0 (2024-02-29)
14.6.0 (2023-12-19)
- Adds 'workflow' to system attributes (6a0bf11)
14.5.0 (2023-11-16)
14.4.0 (2023-08-21)
- Adds 'excludeArchivedItems' client configuration & fixes element endpoint mapping due to API change (19f3fff)
- updates deps & increases required node version (4b0dee3)
14.3.1 (2023-08-02)
14.3.0 (2023-07-31)
- updates deps, migrates to eslint, adds migrate related code fixes (288cbb7)
- typos (3702502)
14.2.0 (2023-06-02)
- adds support for linking items across responses when using toAllPromise items endpoint (67e8e16)
- updates dependencies (b83b3bd)
14.1.0 (2023-05-16)
- rangeFilter now accepts strings, other comparison filters now accept numbers (14e53e8)
- updates deps (3723aa0)
- Preserves linked items order when using items-feed with item mapping (e62d261)
14.0.1 (2023-04-12)
- fixes sync endpoint URL (removes early-access) (0fa47b1)
14.0.0 (2023-04-12)
- Renames
project_id
toenvironment_id
across entire library
13.0.0 (2023-04-12)
- Implements new Sync API models (fixes #363)
- Uses new URL for Sync API endpoints
- adds automatic object linking for linked items / rich text elements in items feed query (c246d31)
- Implements new Sync API models (fixes #363) (28e6f11)
- updates all dependencies (4bde5e1)
- updates dev dependencies (1c5cc70)
- Uses new URL for Sync API endpoints (55fbc11)
12.4.3 (2023-02-20)
- Handles '+' sign in name resolvers (e30f235)
12.4.2 (2022-11-21)
- Adds support for timezone in date elements
12.4.1 (2022-11-01)
- fixes query configuration for initialize sync POST request (42f317c)
12.4.0 (2022-10-27)
- Adds support for 'Sync API' - Initialize sync & sync changes endpoints (60d4198)
- updates dev dependencies (b6b3d16)
- fixes mapping of view content type element query (8c14c39)
12.3.0 (2022-10-05)
- updates dependencies (b8b85e3)
12.2.0 (2022-09-23)
12.1.0 (2022-09-01)
- Handle commas & semicolons in name resolvers (d990dcf)
12.0.2 (2022-07-21)
- Handle '/' character in property name resolvers (9ed6c77)
12.0.1 (2022-07-15)
- escapes property name regex to prevent unintended escaping caused by angular CLI (0913986)
12.0.0 (2022-07-14)
12.0.0-0 (2022-07-14)
11.13.0 (2022-05-23)
- Adds underscore to name resolver when it starts with a number (5a624e3)
- Automatically removes zero width characters from name resolvers (fbf07aa)
- convert snake case name resolver to lowercase only text (df39537)
- Handles '&' in property name resolver (e82ae6d)
- Handles brackets in property name resolver (946db34)
- Improves property name resolvers by handling more special characters and unifies the regex across all name resolvers (d153e81)
- updates dependencies (5830491)
- updates dependencies (a373528)
- fixes property name resolver to cover cases with mixed upper/lower case strings (66918c9)
- Properly sets query headers (some headers were not applied which caused issues especially in combination with paging) (59af6c4)
11.12.0 (2022-04-20)
- Handles '&' in property name resolver (e82ae6d)
11.11.0 (2022-04-20)
- convert snake case name resolver to lowercase only text (df39537)
- Handles brackets in property name resolver (946db34)
11.10.0 (2022-04-20)
- Adds underscore to name resolver when it starts with a number (5a624e3)
11.9.0 (2022-04-20)
- Automatically removes zero width characters from name resolvers (fbf07aa)
11.8.1 (2022-04-20)
- fixes property name resolver to cover cases with mixed upper/lower case strings (66918c9)
11.8.0 (2022-04-20)
- Adds support for strongly typed taxonomy element (c3d85ee)
- Improves property name resolvers by handling more special characters and unifies the regex across all name resolvers (d153e81)
- updates dependencies (a373528)
11.7.0 (2022-03-28)
11.6.0 (2022-03-23)
- updates deps (d899b0b)
11.5.0 (2022-03-14)
11.5.0-1 (2022-03-10)
11.5.0-0 (2022-03-07)
- Adds 'linkedItems' property to Rich text element that contains array or mapped linked items included in the element (fixes #338) (9a48ae5)
- adds ability to preserve 'object' tags in RTE Html (6034f89)
- adds ability to set custom wrap tag for object & json Rich text resolvers (fixes #339) (a6899ff)
- Removes 'object' wrapper tag from resolved Rich text element HTML (fixes #332) (d9f9f74)
- updates deps ( fixes #342) (517501e)
11.4.0 (2022-02-04)
- updates deps (dbb0474)
- adds ability to configure default asset rendition
11.3.0 (2021-12-16)
11.2.1 (2021-12-09)
- use null instead of undefined for asset model properties (da7ff46)
11.2.0 (2021-12-02)
- adds absolute url to rendition record (a6a0ece)
11.1.0 (2021-11-29)
- updates dependencies (b0b3ff5)
11.0.0 (2021-11-16)
11.0.0-11 (2021-10-27)
11.0.0-10 (2021-10-27)
- updates readme, creates base rich text resolvers and uses function to create each and every available resolver (1cf140c)
11.0.0-9 (2021-10-27)
- updates names rich text related async models (231f4f6)
11.0.0-8 (2021-10-26)
- removes remaning usage of browser API in rich text resolver (74d1922)
11.0.0-7 (2021-10-26)
- fixes object / json resolver result (dc03d75)
11.0.0-6 (2021-10-26)
- adds experimental json / object rich text resolvers, simplifies filter classes (326dff6)
- refactors rich text processing by separating parser & rich text resolvers (48b49da)
- separates parser from resolvers and makes resolvers independent on parser implementation, adds experimental json / object rich text element resolvers (24082ec)
- updates deps (f3ccfb9)
11.0.0-5 (2021-10-19)
- fixes value type for LinkedItemsElement (b6cfc8e)
11.0.0-4 (2021-10-14)
- removes log message when content item is not in response (b60f36b)
- use null for instead of undefined for some response models (ff27a93)
- use null for response models (53792f1)
11.0.0-3 (2021-10-14)
- use "string" type for all "Date" properties to support more serialization scenarios
- updates deps, removes duplicate license (035335f)
- use "string" type for all "Date" properties to support more serialization scenarios (909102f)
11.0.0-2 (2021-10-04)
- adds ability to disable mapping of content items in linked items & rich text elements (f67661c)
- adds came case, pascal case & snake case property name resolvers (b422697)
11.0.0-1 (2021-10-01)
- makes rich text resolver generic, uninstalls unused packages, better organizes browser rich text parser code
- makes rich text resolver generic, uninstalls unused packages, better organizes browser rich text parser code (29042b8)
11.0.0-0 (2021-09-30)
- unifies contracts under a shared 'Contracts' namespace
- unifies all response models under common 'Responses' namespace
- converts image transformation enums (ImageFitModeEnum, ImageCompressionEnum, ImageFormatEnum) to types and removes the 'enum' suffix.
- renames 'ImageUrlBuilder' to 'ImageTransformationUrlBuilder'
- converts elements to types instead of interfaces (also removes the 'I' in the type names), adds 'createDeliveryClient' factory function, improves custom element sample
- renames 'IKontentNetworkResponse' and 'IGroupedKontentNetworkResponse' interfaces to 'INetworkResponse' and 'IGroupedNetworkResponse'
- removes query config from mapping service as its no longer necessary due to rich text resolver being separated
- refactors rich text resolver, removes parse5 and default html resolver for node, creates new html resolver for use in browsers and export it with the library
- removes 'itemCodenames' property from LinkedItemsElement because this data is already available in the value property
globalQueryConfig
configuration option was renamed todefaultQueryConfig
- removes _raw properties from content item & element to reduce the size of mapped response & to avoid data duplication
- uses interface for all remaining models & responses
- uses interfaces instead of classes for all responses
- refactors element models by using interfaces instead of classes, changes the ElementResolver to resolve only value instead of the whole custom element
- removes ItemResolver, refactors ContentItem from strongly types class to interface (removes ability to define resolvers on the class level)
- moves elements to 'elements' property within the content item (they were on the content item previously), removes property mapping with reflect metadata, removes collision resolver
- introduces new "IKontentNetworkResponse" model that wraps responses with network related data and separates response specific data for improved mapping of stored json data
- introduces BaseListingQuery for all endpoint with pagination, removes itemsFeedAll method & query, refactors queries to improve their readability, adds missing filter methods, unifies query config and some other minor improvements & changes
- renames withUrl query extension method to withCustomUrl
- renames query extension method 'withParameter' to 'withCustomParameter'. Adds new 'withParameter' method which takes IQueryParameter object similarly as 'withParameters' does for array parameters
- makes SortOrder type instead of enum
- updates kontent-core, removes rxjs from repository in favor of Promises and async based approach
- updates build process (puts all output to "dist" folder), consolidates tests, updates tsconfig
globalQueryConfig
configuration option was renamed todefaultQueryConfig
(8817105)- adds 'createUrlBuilder' factory function (54b5085)
- adds 'withContinuationToken' extension method to all listing queries (a28ddb3)
- adds 'withHeader' query extension method, improves docs of some extension methods (20b9334)
- adds ability to define number of pages to fetch in 'toAllPromise' method (d5d8c2c)
- adds ability to map raw json data with 'map' query extension method (dab3618)
- adds network response tests (0e8b690)
- adds support for 'workflow_step' in content item system attributes (fixes #309) (ad2d965)
- adds support for async browser rich text resolver (ece99b7)
- converts elements to types instead of interfaces (also removes the 'I' in the type names), adds 'createDeliveryClient' factory function, improves custom element sample (2ccb97c)
- converts image transformation enums (ImageFitModeEnum, ImageCompressionEnum, ImageFormatEnum) to types and removes the 'enum' suffix. (d44573a)
- improves typings of raw response data by providing contract types for each query (be654f1)
- introduces BaseListingQuery for all endpoint with pagination, removes itemsFeedAll method & query, refactors queries to improve their readability, adds missing filter methods, unifies query config and some other minor improvements & changes (7c68b8f)
- introduces new "IKontentNetworkResponse" model that wraps responses with network related data and separates response specific data for improved mapping of stored json data (ba4c265)
- makes SortOrder type instead of enum (1d61369)
- moves elements to 'elements' property within the content item (they were on the content item previously), removes property mapping with reflect metadata, removes collision resolver (8f6ed55)
- refactors element models by using interfaces instead of classes, changes the ElementResolver to resolve only value instead of the whole custom element (c3fbd51)
- refactors internal use of headers (stores headers in a single location) (9c0fe73)
- refactors rich text resolver, removes parse5 and default html resolver for node, creates new html resolver for use in browsers and export it with the library (04633a9)
- removes _raw properties from content item & element to reduce the size of mapped response & to avoid data duplication (5c4eb8c)
- removes 'itemCodenames' property from LinkedItemsElement because this data is already available in the value property (acefbe8)
- removes ItemResolver, refactors ContentItem from strongly types class to interface (removes ability to define resolvers on the class level) (039ed29)
- removes query config from mapping service as its no longer necessary due to rich text resolver being separated (748b2f7)
- renames 'IKontentNetworkResponse' and 'IGroupedKontentNetworkResponse' interfaces to 'INetworkResponse' and 'IGroupedNetworkResponse' (9000c14)
- renames 'ImageUrlBuilder' to 'ImageTransformationUrlBuilder' (8124cfe)
- renames query extension method 'withParameter' to 'withCustomParameter'. Adds new 'withParameter' method which takes IQueryParameter object similarly as 'withParameters' does for array parameters (a518694)
- renames withUrl query extension method to withCustomUrl (dbe6b77)
- unifies all response models under common 'Responses' namespace (ad28631)
- unifies contracts under a shared 'Contracts' namespace (41ddd98)
- updates build process (puts all output to "dist" folder), consolidates tests, updates tsconfig (c2946f7)
- updates deps (a18d770)
- updates deps (320d2df)
- updates deps (67da9df)
- updates kontent-core, removes rxjs from repository in favor of Promises and async based approach (b213a7d)
- uses interface for all remaining models & responses (ad7b18d)
- uses interfaces instead of classes for all responses (2cd8cb2)
10.4.1 (2021-03-31)
10.4.0 (2021-03-18)
- adds resolved attribute to BrowserRichTextParser, adds index to every resolved linked item & component within rich text element values (b81d523)
- use switchMap instead of deprecated flatMap operator (59bd752)
10.3.0 (2021-02-05)
10.2.0 (2021-01-08)
- updates dependencies (651ccb4)
- updates internal types of parse5 parser adapter (83109f7)
10.1.0 (2020-11-26)
- adds support for collections
- updates all dependencies, uses axios models directly for request interceptors (5aa5f8b)
10.0.0 (2020-08-25)
- Refactors IQueryParameter to allows value-less parameters which are required by new filtering operators (empty / nempty), adds support for new filter options (fixes #297)
- Refactors IQueryParameter to allows value-less parameters which are required by new filtering operators (empty / nempty), adds support for new filter options (fixes #297) (b2ae46f)
- fixes url resolving test for node.js (212d343)
9.2.1 (2020-08-11)
9.2.0 (2020-07-30)
- updates dependencies, moves error handling logic from core package to sdk + fixes error mapping after recent error response change which now allows null in request_id property (a11e745)
- improves handling of image resolving in rich text element and fixes parse5 parsing in nested component rich text resolver (#294) (9b82718)
9.1.1 (2020-04-02)
- fixes missing attributes in parse5 resolved links with custom html (2e2f8c1)
9.1.0 (2020-03-26)
- exposes richTextParserAdapter via config (62659a6)
9.0.0 (2020-01-20)
- updates deps, refactors retry-strategy which enables specifying either maximum number of attemps or wait time and allows retry of any error even when response is not received (e.g. timeout which could not be retried previously)
- distributes library in esNext format (bd9ea6f)
- refactors item mappers and adds full mapping support to items-feed endpoints (e.g. rich text resolver, url slug resolver, image resolver ..) (6e30485)
- updates deps, refactors retry-strategy which enables specifying either maximum number of attemps or wait time and allows retry of any error even when response is not received (e.g. timeout which could not be retried previously) (b7cf414)
8.2.0 (2019-11-25)
- adds helper method to return linked items as array (fixes #240) (b832f7b)
- extends ContentItem with ability to get all elements in an array (fixes #241) (120918b)
- updates all dependencies (including dev depencies such as the use of latest TypeScript..) (62a9ffc)
8.1.0 (2019-11-18)
- adds support for 'includeTotalCount| parameter (c39a301)
- updates kontent-core package which fixes http retry requests (53a4318)
8.0.0 (2019-10-25)
- Updates @kentico/kontent-core to v4 and uses new and improved retry strategy. 'retryAttempts' configuration option was removed in favor of 'retryStrategy' object.
- adds 'itemsFeedAll' method to get all items from a project. This method may execute multiple HTTP requests. Reworks base responses & debug to allow different debug types per response. (72e03fd)
- adds support for 'items-feed' endpoint (29913c9)
- Updates @kentico/kontent-core to v4 and uses new and improved retry strategy. 'retryAttempts' configuration option was removed in favor of 'retryStrategy' object. (e2abd02)
- prepares instances of all items before resolving occurs to prevent some items from being skipped (5559cb6)
7.2.0 (2019-10-21)
- Enables resolving links without content item representation in response (6472265)
- takes 'isDeveloperMode' settings into account when displaying root debug element (https://github.com/kontent-ai/delivery-sdk-js/issues/255] (7ab56cb)
- updates @kentico/kontent-core dependency which enables configuring axios request (#256) (ea3a504)
7.1.0 (2019-10-14)
- adds hasStaleContent property to all responses and uses new BaseDeliveryResponse base class (3dc5046)