Skip to content

Latest commit

 

History

History
971 lines (686 loc) · 48.5 KB

CHANGELOG.md

File metadata and controls

971 lines (686 loc) · 48.5 KB

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

15.2.0 (2024-09-27)

Features

  • exports optional 'Snippet' type used for strongly typed modelling (96ef2d5)

15.1.1 (2024-09-27)

Bug Fixes

  • re-exports IContentItemElements type (ddc570f)

15.1.0 (2024-09-26)

Features

  • Adds support for constraining item element properties using pre-defined codenames type (c7b16b7)
  • updates deps (03fdc22)

15.0.0 (2024-09-16)

Features

15.0.0-0 (2024-09-10)

⚠ BREAKING CHANGES

  • 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

Features

  • 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)

Upgrading to new RTE parser

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)

Features

  • updates deps (& fixes Axios vulnerability), updates eslint config (ba49770)

14.10.0 (2024-06-28)

Features

14.9.0 (2024-04-29)

Features

14.8.0 (2024-03-06)

Features

  • 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)

Features

Bug Fixes

  • escapes codenames to prevent collisions with javascript constructs (fixes #388) (c5ea589)

14.6.0 (2023-12-19)

Features

  • Adds 'workflow' to system attributes (6a0bf11)

14.5.0 (2023-11-16)

Features

  • updates deps (core-sdk with updated axios) (fixes #382) (df83fdd)

14.4.0 (2023-08-21)

Features

  • 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)

Bug Fixes

  • Reverts language codename check (fixes #372) (227ec5f)

14.3.0 (2023-07-31)

Features

  • updates deps, migrates to eslint, adds migrate related code fixes (288cbb7)

Bug Fixes

14.2.0 (2023-06-02)

Features

  • adds support for linking items across responses when using toAllPromise items endpoint (67e8e16)
  • updates dependencies (b83b3bd)

14.1.0 (2023-05-16)

Features

  • rangeFilter now accepts strings, other comparison filters now accept numbers (14e53e8)
  • updates deps (3723aa0)

Bug Fixes

  • Preserves linked items order when using items-feed with item mapping (e62d261)

14.0.1 (2023-04-12)

Bug Fixes

  • fixes sync endpoint URL (removes early-access) (0fa47b1)

14.0.0 (2023-04-12)

⚠ BREAKING CHANGES

  • Renames project_id to environment_id across entire library

13.0.0 (2023-04-12)

⚠ BREAKING CHANGES

  • Implements new Sync API models (fixes #363)
  • Uses new URL for Sync API endpoints

Features

  • 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)

Bug Fixes

  • 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)

Bug Fixes

  • fixes query configuration for initialize sync POST request (42f317c)

12.4.0 (2022-10-27)

Features

  • Adds support for 'Sync API' - Initialize sync & sync changes endpoints (60d4198)
  • updates dev dependencies (b6b3d16)

Bug Fixes

  • fixes mapping of view content type element query (8c14c39)

12.3.0 (2022-10-05)

Features

12.2.0 (2022-09-23)

Features

  • Preservers the order of mapped linkedItems in RTE (5d9db00)
  • Updates dependencies (0a4d0bf)

12.1.0 (2022-09-01)

Features

  • Handle commas & semicolons in name resolvers (d990dcf)

12.0.2 (2022-07-21)

Bug Fixes

  • Handle '/' character in property name resolvers (9ed6c77)

12.0.1 (2022-07-15)

Bug Fixes

  • 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)

Features

  • 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)

Bug Fixes

  • 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)

Features

  • Handles '&' in property name resolver (e82ae6d)

11.11.0 (2022-04-20)

Features

  • convert snake case name resolver to lowercase only text (df39537)
  • Handles brackets in property name resolver (946db34)

11.10.0 (2022-04-20)

Features

  • Adds underscore to name resolver when it starts with a number (5a624e3)

11.9.0 (2022-04-20)

Features

  • Automatically removes zero width characters from name resolvers (fbf07aa)

11.8.1 (2022-04-20)

Bug Fixes

  • fixes property name resolver to cover cases with mixed upper/lower case strings (66918c9)

11.8.0 (2022-04-20)

Features

  • 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)

Features

  • Adds support for strongly typed taxonomy element (c3d85ee)
  • updates deps (d899b0b)

11.6.0 (2022-03-23)

Features

11.5.0 (2022-03-14)

11.5.0-1 (2022-03-10)

11.5.0-0 (2022-03-07)

Features

  • 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)

Features

  • updates deps (dbb0474)
  • adds ability to configure default asset rendition

11.3.0 (2021-12-16)

Features

  • Adds support for custom asset domains (fixes #333) (c8e70e4)

11.2.1 (2021-12-09)

Bug Fixes

  • use null instead of undefined for asset model properties (da7ff46)

11.2.0 (2021-12-02)

Features

  • adds absolute url to rendition record (a6a0ece)

11.1.0 (2021-11-29)

Features

11.0.0 (2021-11-16)

Features

  • renames INetworkResponse interface to IDeliveryNetworkResponse (e566537)
  • updates deps (42a6ff9)

11.0.0-11 (2021-10-27)

11.0.0-10 (2021-10-27)

Features

  • 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)

Features

  • updates names rich text related async models (231f4f6)

11.0.0-8 (2021-10-26)

Features

  • removes remaning usage of browser API in rich text resolver (74d1922)

11.0.0-7 (2021-10-26)

Bug Fixes

  • fixes object / json resolver result (dc03d75)

11.0.0-6 (2021-10-26)

Features

  • 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)

Bug Fixes

  • fixes value type for LinkedItemsElement (b6cfc8e)

11.0.0-4 (2021-10-14)

Features

  • removes log message when content item is not in response (b60f36b)
  • use null for instead of undefined for some response models (ff27a93)

Bug Fixes

  • use null for response models (53792f1)

11.0.0-3 (2021-10-14)

⚠ BREAKING CHANGES

  • use "string" type for all "Date" properties to support more serialization scenarios

Features

  • 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)

Features

  • 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)

⚠ BREAKING CHANGES

  • makes rich text resolver generic, uninstalls unused packages, better organizes browser rich text parser code

Features

  • makes rich text resolver generic, uninstalls unused packages, better organizes browser rich text parser code (29042b8)

11.0.0-0 (2021-09-30)

⚠ BREAKING CHANGES

  • 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 to defaultQueryConfig
  • 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

Features

  • globalQueryConfig configuration option was renamed to defaultQueryConfig (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)

Features

  • 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)

Features

10.2.0 (2021-01-08)

Features

Bug Fixes

  • updates internal types of parse5 parser adapter (83109f7)

10.1.0 (2020-11-26)

Features

  • adds support for collections
  • updates all dependencies, uses axios models directly for request interceptors (5aa5f8b)

10.0.0 (2020-08-25)

⚠ BREAKING CHANGES

  • Refactors IQueryParameter to allows value-less parameters which are required by new filtering operators (empty / nempty), adds support for new filter options (fixes #297)

Features

  • 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)

Bug Fixes

  • fixes url resolving test for node.js (212d343)

9.2.1 (2020-08-11)

Bug Fixes

  • fixes automatic format for image transformation api (fixes #296) (42204ff)

9.2.0 (2020-07-30)

Features

  • 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)

Bug Fixes

  • 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)

Bug Fixes

  • fixes missing attributes in parse5 resolved links with custom html (2e2f8c1)

9.1.0 (2020-03-26)

Features

  • exposes richTextParserAdapter via config (62659a6)

Bug Fixes

  • fixes #286 & unifies parse5 / browser tests (2a787f4)

9.0.0 (2020-01-20)

⚠ BREAKING CHANGES

  • 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)

Features

  • 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)

Features

  • 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)

Bug Fixes

  • fixes github repo url in package.json & fixes changelog links (fixes #268) (a4132e7)

8.1.0 (2019-11-18)

Features

  • adds support for 'includeTotalCount| parameter (c39a301)

Bug Fixes

  • updates kontent-core package which fixes http retry requests (53a4318)

8.0.0 (2019-10-25)

⚠ BREAKING CHANGES

  • Updates @kentico/kontent-core to v4 and uses new and improved retry strategy. 'retryAttempts' configuration option was removed in favor of 'retryStrategy' object.

Features

  • 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)

Bug Fixes

  • prepares instances of all items before resolving occurs to prevent some items from being skipped (5559cb6)

7.2.0 (2019-10-21)

Features

7.1.0 (2019-10-14)

7.1.0 (2019-10-14)

Features

  • adds hasStaleContent property to all responses and uses new BaseDeliveryResponse base class (3dc5046)

7.0.1 (2019-10-14)