From 5c0573ea7950a5a3e7c554f9786b8f434072768a Mon Sep 17 00:00:00 2001 From: Julia Gru <56249914+julczka@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:06:04 +0200 Subject: [PATCH] add docs and rules endpoints --- .../sources/stylesheet.server.data.ts | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/sources/stylesheet.server.data.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/sources/stylesheet.server.data.ts index de80e00bbe..43edfa7ac1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/sources/stylesheet.server.data.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/repository/sources/stylesheet.server.data.ts @@ -3,6 +3,11 @@ import { DataSourceResponse, UmbDataSource } from '@umbraco-cms/backoffice/repos import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { CreateStylesheetRequestModel, + ExtractRichTextStylesheetRulesRequestModel, + ExtractRichTextStylesheetRulesResponseModel, + InterpolateRichTextStylesheetRequestModel, + InterpolateRichTextStylesheetResponseModel, + RichTextStylesheetRulesResponseModel, StylesheetResource, UpdateStylesheetRequestModel, } from '@umbraco-cms/backoffice/backend-api'; @@ -41,14 +46,77 @@ export class UmbStylesheetServerDataSource if (!path) throw new Error('Path is missing'); return tryExecuteAndNotify(this.#host, StylesheetResource.getStylesheet({ path })); } - + /** + * Creates a new Stylesheet + * + * @param {StylesheetDetails} data + * @return {*} {Promise>} + * @memberof UmbStylesheetServerDataSource + */ insert(data: StylesheetDetails): Promise> { return tryExecuteAndNotify(this.#host, StylesheetResource.postStylesheet({ requestBody: data })); } + /** + * Updates an existing Stylesheet + * + * @param {string} path + * @param {StylesheetDetails} data + * @return {*} {Promise>} + * @memberof UmbStylesheetServerDataSource + */ update(path: string, data: StylesheetDetails): Promise> { return tryExecuteAndNotify(this.#host, StylesheetResource.putStylesheet({ requestBody: data })); } + /** + * Deletes a Stylesheet. + * + * @param {string} path + * @return {*} {Promise} + * @memberof UmbStylesheetServerDataSource + */ delete(path: string): Promise { return tryExecuteAndNotify(this.#host, StylesheetResource.deleteStylesheet({ path })); } + /** + * Get's the rich text rules for a stylesheet + * + * @param {string} path + * @return {*} {(Promise>)} + * @memberof UmbStylesheetServerDataSource + */ + getStylesheetRichTextRules( + path: string + ): Promise> { + return tryExecuteAndNotify(this.#host, StylesheetResource.getStylesheetRichTextRules({ path })); + } + /** + * Extracts the rich text rules from a stylesheet string. In simple words: takes a stylesheet string and returns a array of rules. + * + * @param {ExtractRichTextStylesheetRulesRequestModel} data + * @return {*} {Promise>} + * @memberof UmbStylesheetServerDataSource + */ + postStylesheetRichTextExtractRules( + data: ExtractRichTextStylesheetRulesRequestModel + ): Promise> { + return tryExecuteAndNotify( + this.#host, + StylesheetResource.postStylesheetRichTextExtractRules({ requestBody: data }) + ); + } + /** + * Interpolates the rich text rules from a stylesheet string. In simple words: takes a array of rules and existing content. Returns new content with the rules applied. + * + * @param {InterpolateRichTextStylesheetRequestModel} data + * @return {*} {Promise>} + * @memberof UmbStylesheetServerDataSource + */ + postStylesheetRichTextInterpolateRules( + data: InterpolateRichTextStylesheetRequestModel + ): Promise> { + return tryExecuteAndNotify( + this.#host, + StylesheetResource.postStylesheetRichTextInterpolateRules({ requestBody: data }) + ); + } }