diff --git a/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-paged-response-data.function.ts b/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-paged-response-data.function.ts index 88e5638b9b..2bbe8730d6 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-paged-response-data.function.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-paged-response-data.function.ts @@ -1,6 +1,23 @@ import { DataSourceResponse, UmbPagedData } from '../index.js'; import { Diff } from '@umbraco-cms/backoffice/utils'; +/** + * This function extends the data set of a paged DataSourceResponse. + * Provide the desired type as a generic type parameter. + * This will require the appendData argument to fill in the missing properties of the items. + * @param response {DataSourceResponse>} + * @param appendData {object} Additional properties to append to the data set. + * @returns {DataSourceResponse>} + * + * @example + * + * type originalResponseType = { foo: string }; + * type extendedResponseType = { foo: string, bar: string }; + * + * const extendedResponse = extendDataSourcePagedResponseData(originalResponse, { bar: 'some additional data' }); + * + * extendedResponse.data.items[0].bar is now equal to 'some additional data' + */ export function extendDataSourcePagedResponseData< ExtendedDataType extends IncomingDataType, IncomingDataType extends object = object, diff --git a/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-response-data.function.ts b/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-response-data.function.ts index 2c43336ef0..d962cfe699 100644 --- a/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-response-data.function.ts +++ b/src/Umbraco.Web.UI.Client/src/shared/repository/data-source/extend-data-source-response-data.function.ts @@ -1,6 +1,23 @@ import { DataSourceResponse } from '../index.js'; import { Diff } from '@umbraco-cms/backoffice/utils'; +/** + * This function extends the data set of a DataSourceResponse. + * Provide the desired type as a generic type parameter. + * This will require the appendData argument to fill in the missing properties of the data. + * @param response {DataSourceResponse} + * @param appendData {object} Additional properties to append to the data. + * @returns {DataSourceResponse} + * + * @example + * + * type originalResponseType = { foo: string }; + * type extendedResponseType = { foo: string, bar: string }; + * + * const extendedResponse = extendDataSourceResponseData(originalResponse, { bar: 'some additional data' }); + * + * extendedResponse.data.bar is now equal to 'some additional data' + */ export function extendDataSourceResponseData< ExtendedDataType extends IncomingDataType, IncomingDataType extends object = object,